lung — 2010-09-08T02:57:27-04:00 — #1
Hi,I have problem about convert string format d/m/y to date for insert to database
but i don't know how to convert it
paul_wilkins — 2010-09-08T19:30:24-04:00 — #2
That's a nice idea. Make use of the database features, I like it.
paul_wilkins — 2010-09-08T06:17:22-04:00 — #3
Convert the "UK" formatted string to a date, where dashes are used to tell PHP that it's in d-m-y format:
$ukdate = "15-06-09";
$time = strtotime($ukdate);
$mysqldate = date('Y-m-d H:i:s', $time);
Then $mysqldate will be in an appropriate format to enter in the database.
paul_wilkins — 2010-09-08T04:03:11-04:00 — #4
US date format is m/d/y
UK date format is d-m-y
Notice the difference in separators? If you use those different separators, then functions like strtotime will automatically interpret them correctly for you.
sillysoft — 2010-09-08T13:34:32-04:00 — #5
Another alternative would be using mysqls function str to date.
Just make sure that $date is the same format as %d/%m/%Y
lung — 2010-09-08T04:48:39-04:00 — #6
how to do it?
example string is "15/06/09"
but when i convert is "31/12/1969"
I don't know what's format of datetime for insert to database
What's different if i insert "d/m/y" and "Y/m/d"