Why the date and time is not exact with my timezone? and the data ends with a ":st"...
$time = time();
$tstamp = date("m/d/y h:i:S", $time);
01/21/10 08:28:st
Anyone help??
DATE & TIME
Moderator: General Moderators
Re: DATE & TIME
And what date and time does your computer/server think it is?kennedysee wrote:Why the date and time is not exact with my timezone?
Windows: check the clock on the taskbar (dur)
Unix: run `date`
Because 'S' means "English ordinal suffix for the day of the month, 2 characters".kennedysee wrote:and the data ends with a ":st"
Read the documentation
Re: DATE & TIME
It will show your local machine date/time if you are testing it on local machine. And if you are checking it on live server it will show the server time. You need to mention time zone at the top of your php code in ( date_default_timezone_set(string timezone_identifier) ) function or configure it in php.ini file.
-
kennedysee
- Forum Newbie
- Posts: 14
- Joined: Fri Dec 04, 2009 12:17 am
Re: DATE & TIME
$time = time();
$tstamp = date("m/d/y h:i:s", $time);
if let say, i want to set my timing to GMT+8... how do i do that?
$tstamp = date("m/d/y h:i:s", $time);
if let say, i want to set my timing to GMT+8... how do i do that?
Re: DATE & TIME
You can refer this for time zones http://php.net/manual/en/function.date- ... ne-set.php
Re: DATE & TIME
Of note is the Others, which mentions formats likepbs wrote:You can refer this for time zones http://php.net/manual/en/function.date- ... ne-set.php
Code: Select all
date_default_timezone_set("Etc/GMT-8");
echo date("m/d/y h:i:s");1) The pluses and minuses are reversed from what you think they are
2) They don't account for daylight savings
So don't use them unless you know exactly what you're doing.
-
kennedysee
- Forum Newbie
- Posts: 14
- Joined: Fri Dec 04, 2009 12:17 am
Re: DATE & TIME
tasairis wrote:Of note is the Others, which mentions formats likepbs wrote:You can refer this for time zones http://php.net/manual/en/function.date- ... ne-set.phpButCode: Select all
date_default_timezone_set("Etc/GMT-8"); echo date("m/d/y h:i:s");
1) The pluses and minuses are reversed from what you think they are
2) They don't account for daylight savings
So don't use them unless you know exactly what you're doing.
THANKS ALOT