Split Date into 3 variables

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
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Split Date into 3 variables

Post by donny »

hello,

i have a form that selects the date. it posts data as 03/05/2014 in 1 variable.. can someone tell me how i can implode it so that i can split the month day year

$date ="03/05/2014";

$date_month = $date['1'];
$date_day = $date['2'];
$date_year = $date['3'];


something like that i am guessing..
donny
Forum Contributor
Posts: 179
Joined: Mon Aug 11, 2014 11:18 am

Re: Split Date into 3 variables

Post by donny »

explode worked fine.
thank you
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Split Date into 3 variables

Post by Celauran »

Depending on why you're doing this, it may be better to just instantiate a DateTime object.
Post Reply