Okay, i have a form where user enter the date in this format DD-MM-YYYY.
This needs to get inserted into a date field in my database. But the date field is formatted YYYY-MM-DD.
Is there something a can do in the query to format the date correctly, or will i have to format it using PHP first?
Thanks
Mark
Inserting date into MySQL
Moderator: General Moderators
Maybe explode() might help. Here's how I'd do it:
Hope that helps Bech,
-Nay
Code: Select all
<?php
$date = "20-10-2003"; // of $_POST['date'] or something
$arr = explode("-", $date);
$new = <<< DATE
{$arr[2]}-{$arr[1]}-{$arr[0]}
DATE;
echo $new;
?>-Nay
I'm still having a read through but maybe this might do:
http://www.mysql.com/doc/en/Date_and_ti ... tions.html
-Nay
http://www.mysql.com/doc/en/Date_and_ti ... tions.html
-Nay