Page 1 of 1

I have a Date/Time problem

Posted: Mon Aug 16, 2004 11:46 pm
by myleow
I will be receiving Date Time format that conform to ISO 8601 format.

Code: Select all

$date1 = '20040816T202020Z';
and

Code: Select all

$date2 = '2004-08-16T22:20:20+02:00';
I need to compare both $date1 and $date2, a simple > won't work because of the hyphens. Is there a way to do this with a premade function?

Another question is the +02:00 for $date2 is the time zone indication, is there a possibility that that doesn't exist?

Regards
Mian

Posted: Tue Aug 17, 2004 3:35 am
by Grim...
I don't know of a function, but you could do:

Code: Select all

<?php
$chararray = array("-", ":");
$date3 = str_replace($chararray, "", substr($date2, 0, -6));

if ($date1 > $date3)
{
    //Carry on
?>