Page 1 of 1

date function

Posted: Wed Sep 28, 2005 11:55 pm
by dude81
how to diffrentiate date-month-year with current date-month and year, individually,
I wrote a logic on it, I was enough confident it will not work,
the logic is here

Code: Select all

if( (($par_dt[0] >= $even_dt[0]) || ($par_dt[1] >= $even_dt[1]) || ($par_dt[2]>= $even_dt[2]) || ($event_status == 'Open'))  || (($par_dt[0] < $even_dt[0]) || ($par_dt[1]< $even_dt[1]) || ($par_dt[2] < $even_dt[2]) && ($event_status == 'Open')))
where par_dt[0] gets date and 1 gets month and 2 gets year
but this doesnt work

Posted: Thu Sep 29, 2005 12:17 am
by ruchit
your can use

Code: Select all

$dateparts=explode('-', $date); //assuming that the format is dd-mm-yyyy
$dateparts=explode('/', $date); //assuming that the format is dd/mm/yyyy

Posted: Thu Sep 29, 2005 1:16 am
by dude81
[SOLVED]
cool..it works gr8 now 8O
Thank you

Re: date function

Posted: Thu Sep 29, 2005 2:37 am
by omega-systems
Or you can use this solution:
if ( !isset($date) || !preg_match("/^(((([0-9]?)([0-9])(\/|\.|-))){2})(([0-9]){4})$/", $date, $matches) )
{
return false;
}
list ($month, $day, $year) = split('[/.-]', $date);

Regards,
Omega Systems Ltd
Email: info@omega-systems.biz
ICQ: 264962449
MSN: omega-systems@hotmail.com
AIM: OmegaSys Ltd

Posted: Thu Sep 29, 2005 3:47 am
by ruchit
well omega if its an seo exercise its good... but generally, we suggest better methods if we have to a solved problem otherwise....
its like either you can go straight or you can take a right, then a left, a u-turn from there &.....