CodeIgniter Forums
now() is not always gmdate - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: now() is not always gmdate (/showthread.php?tid=33150)



now() is not always gmdate - El Forum - 08-17-2010

[eluser]qwang[/eluser]
i use date hlper's now() function to generate a gmt date
but i found under different environment
the time is not always gmt date

my test evn is using xampp under windows, and now() returns gmt date
but under my server which is linux, now() returns server time

so anyone meets this problem, and how did you do to solve this
thank you


now() is not always gmdate - El Forum - 08-17-2010

[eluser]Clooner[/eluser]
[quote author="qwang" date="1282069329"]i use date hlper's now() function to generate a gmt date
but i found under different environment
the time is not always gmt date

my test evn is using xampp under windows, and now() returns gmt date
but under my server which is linux, now() returns server time

so anyone meets this problem, and how did you do to solve this
thank you[/quote]afaik now() won't return gmt by default. You will have to enable it in the config file and it has to be correctly configured in the server


now() is not always gmdate - El Forum - 08-17-2010

[eluser]qwang[/eluser]
thanks Jeroen
i checked again the config.php and found that as your post said, i missed to change the server's config.php
so now() returns gmt date
i have another question as belows
echo "GMT Time:" . gmdate('Y-m-d H:iConfused', time());
echo "<br />";
$now = time();
$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
echo "GMT Time 2:" . gmdate('Y-m-d H:iConfused', $system_time);
echo "<br />";

i found that the two GMT time returned by gmdate() is different, and don't know why
ci use the second method, can you give me some explanation, thank you