Php accompanied by a useful function to display information about the date and hour of the server at once, namely by using the function date(). (Note: function date() is not equal to several time zones).
date function syntax is as follows:
description:date("Y-m-d H:i:s");
- Y = year;
- m = months;
- d = date;
- H = hours;
- i = min;
- s = seconds;
<?phpdisplay the results were:
echo date("Y-m-d H:i:s");
?>
- 2011-08-22 01:30:39
- 2011-08-22 00:30:39
Suppose your computer is set to GMT +7. So that the time displayed by the php with the time available on the client computer, then the php syntax becomes:
<?phpSo now php show time:
echo gmdate("Y-m-d H:i:s");
?>
- 2011-08-22 00:30:39
You can also develop their own syntax, for example:
<?phpthen try the syntax-the syntax above, what is happening. Good luck and be creative.
echo date("Y-m-d H:i:s"); # Waktu server Apache
echo ' – Server <br>';
echo gmdate("Y-m-d H:i:s"); #Waktu GMT
echo ' – GMT <br>';
echo gmdate("Y-m-d H:i:s", time()+60*60*7); # WIB
echo ' – WIB <br>';
?>
No comments:
Post a Comment