Page 1 of 1
DATE & TIME
Posted: Tue Jan 05, 2010 12:20 am
by kennedysee
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??
Re: DATE & TIME
Posted: Tue Jan 05, 2010 12:25 am
by requinix
kennedysee wrote:Why the date and time is not exact with my timezone?
And what date and time does your computer/server think it is?
Windows: check the clock on the taskbar (dur)
Unix: run `date`
kennedysee wrote:and the data ends with a ":st"
Because 'S' means "English ordinal suffix for the day of the month, 2 characters".
Read the documentation
Re: DATE & TIME
Posted: Tue Jan 05, 2010 12:46 am
by pbs
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.
Re: DATE & TIME
Posted: Tue Jan 05, 2010 12:56 am
by kennedysee
$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?
Re: DATE & TIME
Posted: Tue Jan 05, 2010 1:28 am
by pbs
Re: DATE & TIME
Posted: Tue Jan 05, 2010 2:12 am
by requinix
Of note is the Others, which mentions formats like
Code: Select all
date_default_timezone_set("Etc/GMT-8");
echo date("m/d/y h:i:s");
But
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.
Re: DATE & TIME
Posted: Tue Jan 05, 2010 9:38 am
by kennedysee
tasairis wrote:
Of note is the Others, which mentions formats like
Code: Select all
date_default_timezone_set("Etc/GMT-8");
echo date("m/d/y h:i:s");
But
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
