date function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

date function

Post 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
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post 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
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

[SOLVED]
cool..it works gr8 now 8O
Thank you
omega-systems
Forum Newbie
Posts: 14
Joined: Tue Sep 27, 2005 5:01 am
Contact:

Re: date function

Post 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
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post 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 &.....
Post Reply