Connecting Tech Pros Worldwide Help | Site Map

Changing between times

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 7th, 2006, 04:25 PM
Iain Adams
Guest
 
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


  #2  
Old August 7th, 2006, 04:45 PM
ZeldorBlat
Guest
 
Posts: n/a
Default Re: Changing between times


Iain Adams wrote:
Quote:
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);

  #3  
Old August 8th, 2006, 11:15 AM
Iain Adams
Guest
 
Posts: n/a
Default Re: Changing between times

Hey,

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

ZeldorBlat wrote:
Quote:
Iain Adams wrote:
Quote:
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);
  #4  
Old August 8th, 2006, 02:55 PM
Rik
Guest
 
Posts: n/a
Default Re: Changing between times

Iain Adams wrote:
Quote:
ZeldorBlat wrote:
Quote:
>Iain Adams wrote:
Quote:
>>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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.