<?php
// returns false
echo checkdate(2,30,2005) ? "valid" : "invalid";
// returns true
echo checkdate(4,6,2010) ? "valid" : "invalid";
?>
getdate($ts)
在没有自变量的情况下,该函数以结合数组的方式返回当前日期与时间。数组中的每个元素代表日期/时间值中的一个特定组成部分。可向函数提交可选的时间标签自变量,以获得与时间标签对应的日期/时间值。
应用此函数来获得一系列离散的,容易分离的日期/时间值。
<?php // get date as associative array $arr = getdate(); echo "date is " . $arr['mday'] . " " . $arr['weekday'] . " " . $arr['year']; echo "time is " . $arr['hours'] . ":" . $arr['minutes']; ?> |
<?php // returns timestamp for 13:15:23 7-jun-2006 echo mktime(13,15,23,6,7,2006); ?> |
<?php // format current date // returns "13-sep-2005 01:16 pm" echo date("d-m-y h:i a", mktime()); ?> |
<?php // returns 13-sep-05 echo date("d-m-y", strtotime("today")); // returns 14-sep-05 echo date("d-m-y", strtotime("tomorrow")); // returns 16-sep-05 echo date("d-m-y", strtotime("today +3 days")); ?> |
<?php // set locale to france (on windows) setlocale(lc_time, "fra_fra"); // format month/day names // as per locale setting // returns "septembre" and "mardi" echo strftime("month: %b "); echo strftime("day: %a "); ?> |
<?php // get starting value $start = microtime(); // run some code for ($x=0; $x<1000; $x++) { $null = $x * $x; } // get ending value $end = microtime(); // calculate time taken for code execution echo "elapsed time: " . ($end - $start) ." sec"; ?> |
<?php // returns timestamp for 12:25:23 9-jul-2006 echo gmmktime(12,25,23,7,9,2006); ?> |
<?php // format current date into gmt // returns "13-sep-2005 08:32 am" echo gmdate("d-m-y h:i a", mktime()); ?> |
<?php // set timezone to utc date_default_timezone_set('utc'); ?> |
如对本文有疑问, 点击进行留言回复!!
php 使用 yansongda/pay 进行微信,支付宝支付
Codeforces Round #658 (Div. 2) (C1、C2)
van-uploader + thinkphp6.0 图片上传
网友评论