Im creating a time-base site wherein the timestamp should rely on the global time
and not to my PC's time (because it can be out-dated somethimes).
How can I do that?
Unless is specified by localtime(), time_zone cookies and so on, PHP works with the server time, not with client time, if you want to use GMT then use gmdate():
<?php echo gmdate('c'); echo date('c'); ?>
Thanks for the reply. How can it know the time in your location? The time in the east is different from the west.
If the user register to the website you can ask for the timezone location, at that point your script becomes:
<?php date_default_timezone_set('Europe/London'); # or America/New_York echo gmdate('c') . "\n"; echo date('c') . "\n"; ?>
You're welcome :)
I have some concerns again...
I tried your code:
<?php date_default_timezone_set('GMT+8'); echo gmdate('c') . "\n"; echo date('c') . "\n"; ?>
Yes it did show up some dates but the date is still machine date..
2011-29-08, 01.52.45 am //result on gmdate();
2011-08-29T01:52:45+00:00 //result on date();
The exact time now here is 10am.
Seems something is wrong..
What do you think?
i got it! :))