- 论坛徽章:
- 0
|
- <?php
-
//默认设置为上海时区
-
date_default_timezone_set('Asia/Shanghai');
-
-
//1 checkdate 验证日期
-
echo "april 31,2007".(checkdate(4,31,27)? 'valid':'invalid');
-
echo "<br />";
-
-
//2 格式化日期和时间 date
-
echo date("m-d-Y");
-
echo "<br />";
-
echo "the time is".date("h:i:s");
-
echo "<br />";
-
-
//了解当前时间的更多信息 gettimeofday
-
date_default_timezone_set('Asia/Shanghai');
-
$time = gettimeofday();
-
$GMToffset = $time['minuteswest'] / 60;
-
printf("server location is %d hours west of GMT.",$GMToffset);
-
echo "<br />";
-
-
//时间戳
-
echo time();
-
echo "<br />";
-
echo date("F d,Y h:i:s",time());
-
?>
- april 31,2007invalid
-
08-25-2011
-
the time is06:04:06
-
server location is -8 hours west of GMT.
-
1314266646
-
August 25,2011 06:04:06
|
|