Changing between times

This is a discussion on Changing between times within the PHP Language forums, part of the PHP Programming Forums category; hey does anyone know to convert a time string in the form dd-mm-yyyyThh:mm:ss i.e 2006-...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-07-2006
Iain Adams
 
Posts: n/a
Default Changing between times

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

Reply With Quote
  #2 (permalink)  
Old 08-07-2006
ZeldorBlat
 
Posts: n/a
Default Re: Changing between times


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);

Reply With Quote
  #3 (permalink)  
Old 08-08-2006
Iain Adams
 
Posts: n/a
Default Re: Changing between times

Hey,

When I try that I unfortunetely get -1. Any other ideas?

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);


Reply With Quote
  #4 (permalink)  
Old 08-08-2006
Rik
 
Posts: n/a
Default Re: Changing between times

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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0