Jump to content

[SOLVED] strtotime ?


ainoy31

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/81305-solved-strtotime/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/81305-solved-strtotime/#findComment-412665
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/81305-solved-strtotime/#findComment-412667
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.