Hi,
I am creating a countdown timer.
http://www.agrizlive.com/countdown/index.php
If you select "Countdown End Date" to 1st november, It works fine. But if i select 1st december, then it shows one extra hour.
also, my strtotime function returns the following timestamp for New Year.
$d = "2011-01-01 0:0:0";
echo strtotime($d); //1293861600
In that counter i gave 2010-01-01 00:00:00 // Works fine.
In that counter i gave 2011-01-01 00:00:00 // There is a problem.
Please give me advice on this.
Regards
Mahesh
Problem with PHP Timestamp
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Problem with PHP Timestamp
Daylight Saving Time? This year it ends November 7th, so your code is likely correct.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Problem with PHP Timestamp
Hi,
Thanks for the information.
Yes. It is daylight saving.
Is there a way to fix it?
Regards
Mahesh
Thanks for the information.
Yes. It is daylight saving.
Is there a way to fix it?
Regards
Mahesh
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Problem with PHP Timestamp
I don't know how you are doing your calculations, but you can probably calculate it in a timezone that doesn't observe daylight saving time like GMT/UTC:agriz wrote:Hi,
Thanks for the information.
Yes. It is daylight saving.
Is there a way to fix it?
Regards
Mahesh
Code: Select all
$diff = strtotime($future . ' UTC') - strtotime($now . ' UTC');mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Problem with PHP Timestamp
Amazing and awesome.
Short and sweet solution. Adding utc fixed the problem.
Thanks for your help
Regards
Mahesh
Short and sweet solution. Adding utc fixed the problem.
Thanks for your help
Regards
Mahesh