Page 1 of 1
date manipulation
Posted: Wed Mar 31, 2004 11:50 am
by serap
I have a problem with the dates, I just wonder if I can do something about it or wether it is a server issue:
all the dates we insert is inserted in the US format yyyy-mm-yy.
Can we insert it in the dd-mm-yyyy format just by using the DATE_FORMAT() withut needing to change the server setings (we dont have access to it).
If not we will need format it before INSERTING and after QUERYING each time and that would be...not good???
thanks,
Posted: Wed Mar 31, 2004 12:35 pm
by twigletmac
Don't format it when inserting - it should be put into a proper date column with the proper format. Only change the format when you select the date for display, that's not a prob.
Mac
Posted: Wed Mar 31, 2004 12:38 pm
by serap
what if the users so not want to write it in the yyyy-mm-dd format then I have to?
Posted: Wed Mar 31, 2004 12:50 pm
by magicrobotmonkey
dont let them write it. On the form use three separate inputs then concatenate them before inserting
Posted: Wed Mar 31, 2004 6:26 pm
by Pyrite
Ps. YYYY-MM-DD is NOT the US Date Format, it is The international standard date notation. Americans prefer MM-DD-YY.
Posted: Wed Mar 31, 2004 7:46 pm
by JAM
Sweds likely use YYMMDD. So even there is a difference, slight, but still.
As magicrobotmonkey mention, the use of more than one form-field might be interesting, if that helps you. Be sure to check the [php_man]checkdate[/php_man]() function as well. It might be useful.
Posted: Thu Apr 01, 2004 3:12 pm
by Steveo31
I found the solution searching here at home last night. I don't have the link, but it was something like:
Code: Select all
<?php
$getDate = mysql_query("SELECT DATE_FORMAT('theDate', '%c-%e-%y') AS theDate FROM the_table";
$row = mysql_fetch_array($getDate, MYSQL_ASSOC);
$newDate = $row['theDate'];
echo $newDate;
?>
Something like that... I'll take a looksy when I get home and if it is wrong I'll correct myself.
