Bao's drafts

Random posting
Jun 10
Permalink

gmmktime vs mktime

<?php

error_reporting(E_ALL);

date_default_timezone_set(“Asia/Ho_Chi_Minh”);
//date_default_timezone_set(“America/Los_Angeles”);

echo “offset: ” . date(“P”) . “<br/>”;

$format = “Y-m-d H:i:s”;

$time = time();
$mktime = mktime(date(“H”)); // timezone stamp
$gmtime = gmmktime(date(“H”)); // 2 x timezone stamp
$gmtime2 = strtotime(gmdate(“Y-m-d H:i:s”)); // gmt stamp

echo date($format) . “<br/>”;
echo gmdate($format) . “<br/>”;

echo “$time ” . date($format,$time) . “<br/>”;
echo “$mktime ” . date($format,$mktime) . “<br/>”;
echo “$gmtime ” . date($format,$gmtime) . “<br/>”;
echo “$gmtime2 ” . date($format,$gmtime2) . “<br/>”;

// fact: timestamp does not contain information about timezone

Comments (View)
blog comments powered by Disqus