Reply to Re: Changing between times

Your name:

Reply:


Posted by Rik on 08/08/06 15:05

Iain Adams wrote:
> ZeldorBlat wrote:
>> Iain Adams wrote:
>>> hey
>>> does anyone know to convert a time string in the form
>>> dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix
>>> time stamp or something that at least I can use to compare to a unix
>>> timestamp.
>>>
>>> Hope that makes sense
>>
>> $string = '2006-08-01T15:45:11-00:00';
>> $timestamp = strtotime($string);
> When I try that I unfortunetely get -1. Any other ideas?

Don't you mean the datatimestring should be '2006-08-01T15:45:11' instead of
'2006-08-01T15:45:11-00:00'?

If yes:
list($date,$time) = explode('T',$string);
list($year,$month,$day) = explode('-',$date);
list($hour,$minute,$second) = explode(':',$time);
$time = mktime($hour,$minute,$second,$month,$day,$year);

If not:
list($date,$time) = explode('T',$string);
list($year,$month,$day) = explode('-',$date);
$time = substr($time,0,8);
list($hour,$minute,$second) = explode(':',$time);
$time = mktime($hour,$minute,$second,$month,$day,$year);

Grtz,
--
Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация