Copy CodeThe code is as follows:
echo Mktime (11,25,0,9,5,2010);//the same as time
Echo Microtime ();
echo Mktime (0,0,0,1,1,1970);
?>
The output is 1283657290, 1283657100, 0.88533200 1283657290, 25200, respectively. From the last value, we know that the timestamp returned here is time-zone adjusted, that is, my January 1, 1970 in China 0 o'clock, Greenwich has not reached 0 points, so the time here will be negative and the whole good equals -8*3600.
Look again
Copy CodeThe code is as follows:
echo Date ("H i l D F", 1283657100);
Echo gmdate ("H i l D F", 1283657100);
Echo strftime ("%hh%m%A%d%b", 1283657100);
Strftime () does not work the same way as date (), except that a percent semicolon must be added before the special formatting character.
Echo strtotime ("2010-9-5 11:25:00");
Var_dump (GETDATE (Time ()));
?>
The output here is Sunday September, Sunday September, 11h25 Sunday Sep, 1283657100, Array (11) {
["Seconds"]=>
Int (9)
["Minutes"]=>
Int (39)
["Hours"]=>
Int (11)
["Mday"]=>
Int (5)
["Wday"]=>
Int (0)
["Mon"]=>
Int (9)
["Year"]=>
Int (2010)
["Yday"]=>
Int (247)
["Weekday"]=>
String (6) "Sunday"
["Month"]=>
String (9) "September"
[0]=>
Int (1283657949)
}
Mainly look at the third output, where the output is in China's September 5, 2010 11:25 GMT time is how much. The time difference is also included here. And here's another wonderful thing is that only gmdate did not issue a warning, and the rest were warned that they could not rely on the system's time zone. Imagine also, because Gmdate calculated only Greenwich time, even if the system time zone is wrong, one plus one minus is normal again.
Copy CodeThe code is as follows:
Time formatting
function Sgmdate ($dateformat, $timestamp = ", $format =0) {
Global $_sconfig, $_sglobal;
if (empty ($timestamp)) {
$timestamp = $_sglobal[' timestamp ');
}
$timeoffset = strlen ($_sglobal[' member ' [' Timeoffset ']) >0?intval ($_sglobal[' member ' [' Timeoffset ']): Intval ($_ sconfig[' Timeoffset ');
$result = ";
if ($format) {
$time = $_sglobal[' timestamp ')-$timestamp;
if ($time > 24*3600) {
$result = Gmdate ($dateformat, $timestamp + $timeoffset * 3600);
} elseif ($time > 3600) {
$result = Intval ($time/3600). Lang (' Hour '). Lang (' before ');
} elseif ($time > 60) {
$result = Intval ($time/60). Lang (' minute '). Lang (' before ');
} elseif ($time > 0) {
$result = $time. Lang (' second '). Lang (' before ');
} else {
$result = lang (' Now ');
}
} else {
$result = Gmdate ($dateformat, $timestamp + $timeoffset * 3600);
}
return $result;
}
We look directly at what is in the IF ($format) {}, and we first get the difference between the current time of the system and the time I passed in (typically, the time in the database, such as 2010-9-4 21:00:00). If the time difference is within one day, then direct conclusions such as two hours ago, if it is greater than 1 days, call gmdate. I just don't understand it here. Why call this weird function instead of the direct date ($timestamp)? What the hell is that supposed to mean?
Gmdate
When Run is Finland (GMT +0200), the first line below prints "Jan 1998 00:00:00" while the second prints "Dec 31 1997 22:00:00 ".
Copy CodeThe code is as follows:
echo Date ("M D Y h:i:s", mktime (0, 0, 0, 1, 1, 1998));
Echo gmdate ("M D Y h:i:s", mktime (0, 0, 0, 1, 1, 1998));
?>
That is to say Gmdate has considered the time difference. This will output the standard time format, not a few days ago.
Next, focus on the functions in the Function_common of Uchome.
Copy CodeThe code is as follows:
String time-of-day
function Sstrtotime ($string) {
Global $_sglobal, $_sconfig;
$time = ";
if ($string) {
$time = Strtotime ($string);
if (gmdate (' h:i ', $_sglobal[' timestamp ') + $_sconfig[' timeoffset '] * 3600)! = Date (' h:i ', $_sglobal[' timestamp '])) {
$time = $time-$_sconfig[' timeoffset '] * 3600;
}
}
return $time;
}
Although this function is very few, but I am very hard to see. This is to convert a time string to a timestamp. For example, I entered here is 2010 9 4 21:08, then the value of the hour is the time to January 1 1970 00:00:00 GMT, here is to consider the difference. The values of $_sglobal[' timestamp] are actually calculated in the same way as in the case of the other, but there may be a small difference in values. $_sconfig[' Timeoffset ' is inside the config table, which currently has a value of 8. One situation here is that the system's time zone is correct, or not, and needs to be tested by $_sconfig[' Timeoffset '. Gmdate passes the time stamp (the timestamp of the place where the program was run) through the system's time zone to get to that place in Greenwich. If the system time zone is set to the right, then this is just a plus minus, and the back of the equivalent (in fact, here $_sglobal["timestamp" value is irrelevant). If it is normal, then you do not need to change to the moment, if it is not normal, then need to reduce. But what the hell is that supposed to mean?
http://www.bkjia.com/PHPjc/322864.html www.bkjia.com true http://www.bkjia.com/PHPjc/322864.html techarticle Copy the code as follows:? PHP echo Time (), Echo mktime (11,25,0,9,5,2010);//Echo Microtime () as Time; Echo Mktime (0,0,0,1,1,1970); ? The output is 1283657290 、...