ainoy31 Posted December 12, 2007 Share Posted December 12, 2007 Hello- I need a second eye on this. I have a date format that is in 22/12/2007. I pass this data over to the next page to convert into 2007-12-22. However, this is my issue. Instead, I get a date of 1969-12-31. Here is my code: $date = $_POST["ship_date"]; $ship_date = date("Y-m-d", $strtotime($date)); echo "Ship Date: " . $ship_date . "<br>"; Much appreciation. AM Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 12, 2007 Share Posted December 12, 2007 $strtotime($date)); if strtotime is supposed to be a function there shouldn't be a $ in front of it $ (dollar signs) precede variables, not functions Quote Link to comment Share on other sites More sharing options...
ainoy31 Posted December 12, 2007 Author Share Posted December 12, 2007 That was I typo on my part. $date = $_POST["ship_date"]; $ship_date = date("Y-m-d", strtotime($date)); I still get the 1969-12-31 value. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2007 Share Posted December 12, 2007 from my expierience I don't think it accepts dd/mm/yyyy format it however accepts mm/dd/yyyy format. Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 12, 2007 Share Posted December 12, 2007 if strtotime() has trouble accepting your format and you can use mktime() to send in the parameters manually, you can parse the date string yourself to get the arguments Quote Link to comment Share on other sites More sharing options...
Lumio Posted December 12, 2007 Share Posted December 12, 2007 what is in $_POST['ship_date']? Maybe not that, what you need Quote Link to comment Share on other sites More sharing options...
ainoy31 Posted December 12, 2007 Author Share Posted December 12, 2007 Here is my solution: $date = $_POST["ship_date"]; $d = explode('/', $date); $yr = $d[2]; $mo = $d[1]; $dy = $d[0]; $ar = array('year' => $yr, 'mon' => $mo, 'day' => $dy); $ship_date = implode("-", $ar); echo "Ship Date: " . $ship_date . "<br>"; This gave me the format that I needed. yyyy-mm-dd. Thanks for all the suggestions. Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 12, 2007 Share Posted December 12, 2007 Here is my solution: $date = $_POST["ship_date"]; $d = explode('/', $date); $yr = $d[2]; $mo = $d[1]; $dy = $d[0]; $ar = array('year' => $yr, 'mon' => $mo, 'day' => $dy); $ship_date = implode("-", $ar); echo "Ship Date: " . $ship_date . "<br>"; This gave me the format that I needed. yyyy-mm-dd. Thanks for all the suggestions. what does explode & implode do. Never heard of them before. Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 12, 2007 Share Posted December 12, 2007 what does explode & implode do. Never heard of them before. I heard someone mention the word "google" the other day. What does it mean/do? Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 12, 2007 Share Posted December 12, 2007 was only a question, never heard them used in a php script Quote Link to comment 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.