php_begins Posted March 6, 2012 Share Posted March 6, 2012 I have a date of the following format: $date='04/09/2012'; How can i split it so that I can each one of them separately to use it in a JS function. var myDate = new Date(2012, 4, 9); NOTE: javascript months run from 0 to 11 for Jan to Dec. Quote Link to comment https://forums.phpfreaks.com/topic/258355-split-dates-to-include-in-a-js-function/ Share on other sites More sharing options...
php_begins Posted March 6, 2012 Author Share Posted March 6, 2012 Never mind..here is what i did. $split_date=explode("/",$date); echo "0: ".$split_date[0]."<br>"; echo "1: ".$split_date[1]."<br>"; echo "2: ".$split_date[2]."<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/258355-split-dates-to-include-in-a-js-function/#findComment-1324349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.