MENU
Timestamp
time() returns the current Unix timestamp, which is the number of seconds since 1 Jan 1970 Midnight GMT. microtime($b) returns the current Unix timestamp with microseconds. If $b is true, a float instead of a string is returned. gettimeofday($b) returns the current Unix timestamp. If $b is true, a float instead of an array is returned. mktime([$i1[, $i2[, $i3[, $i4[, $i5[, $i6]]]]]]) returns a Unix timestamp for the date and time. The parameters are respectively the hour, minute, second, month, day and year. gmmktime(……) is similar to mktime(……) except that the passed parameters represent a GMT date.timestamp.php:
<!DOCTYPE html><html><head></head>
<body><?php
echo time()."<br />";
echo microtime()."<br />";
echo microtime(true)."<br />";
echo gettimeofday(true)."<br />";
print_r(gettimeofday()); echo "<br /><br />";
echo mktime(23,59,59,12,30,2012)."<br />";
echo gmmktime(23,59,59,12,30,2012)."<br />";
?></body></html>
1353229775 0.16088300 1353229775 1353229775.1609 1353229775.1609 Array ( [sec] => 1353229775 [usec] => 160895 [minuteswest] => -60 [dsttime] => 0 ) 1356908399 1356911999
<!DOCTYPE html><html><head></head>
<body><?php
echo date('d-M-Y h:i:sa')."<br />";
echo gmdate('d-M-Y h:i:sa')."<br />";
echo idate('Y')."<br />";
print_r(getdate()); echo "<br />";
print_r(localtime()); echo "<br />";
print_r(localtime(time(),true)); echo "<br />";
echo strtotime('30-12-2012')."<br />";
echo strtotime('now')."<br />";
echo strtotime('yesterday')."<br />";
echo strtotime('+1 day')."<br />";
echo strtotime('+1 week')."<br />";
echo strtotime('+1 week 2 days 4 hours 2 seconds')."<br />";
echo strtotime('next Thursday')."<br />";
echo strtotime('last Monday')."<br />";
echo strtotime('2000-12-25 18:30:30')."<br />";
echo strtotime('2000:12:25 18:30:30')."<br />";
?></body></html>
18-Nov-2012 11:10:39am 18-Nov-2012 10:10:39am 2012 Array ( [seconds] => 39 [minutes] => 10 [hours] => 11 [mday] => 18 [wday] => 0 [mon] => 11 [year] => 2012 [yday] => 322 [weekday] => Sunday [month] => November [0] => 1353233439 ) Array ( [0] => 39 [1] => 10 [2] => 11 [3] => 18 [4] => 10 [5] => 112 [6] => 0 [7] => 322 [8] => 0 ) Array ( [tm_sec] => 39 [tm_min] => 10 [tm_hour] => 11 [tm_mday] => 18 [tm_mon] => 10 [tm_year] => 112 [tm_wday] => 0 [tm_yday] => 322 [tm_isdst] => 0 ) 1356822000 1353233439 1353106800 1353319839 1353838239 1354025441 1353538800 1352674800 977765430 977765430