|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Mysql date formats
Hey everyone,
Who knows how to change the date format to dd-mm-yyyy I have the next situation. I use php for a site and i have a form with the field 'date' this field i like to set to dd-mm-yyyy Now this field is text, and it must be date. but the user dont type the date as yyyy-dd-mm Thx Alex |
|
#2
|
||||
|
||||
|
You'll regret it later if you don't use the default date field. Instead, use php to flip the date as needed:
PHP Code:
$sql = "INSERT INTO table SET date='" . flip_date($_POST['date']) . "'"; And validate the user input. |
|
#3
|
|||
|
|||
|
Personally, I'd go with strtotime() and then date(), but then I'd also be using timestamps instead of date/time strings so...
No, I lie: I'd force the user to choose a month and a day (say, from a <select>) and then let them type in a year. Then format it accordingly. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Mysql date formats |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|