Jump to content

Date Format when inserting data


scadran

Recommended Posts

<?php
$date = "14/03/07";
$datearray = explode("/", $date); //explode the date via the "/"
$newdate = "$datearray[1]/$datearray[0]/$datearray[2]"; //rearrange the date for the strtotime format to work properly
$newerdate = strtotime($newdate); //create the timestamp
$insertdate("Y-m-d", $newerdate); //create the date object from the timestamp in mysql format
?>

~chigley,

Unfortunately, strtotime does not recognise dd/mm/yy format . Try 25/12/07

 

<?php
$date = '25/12/07';
list ($d,$m.$y) = explode ('/', $date);
$dbdate = "$y-$m-$d";              // write this to the db if you have DATE or DATETIME field
$tstamp = strtotime($dbdate );   // write this to the db if you have timestamp field

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.