MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 18th, 2007, 05:21 PM
alexknobe alexknobe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 alexknobe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 11 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old May 19th, 2007, 06:09 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 223 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 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:
function flip_date($date) {
$tmp explode("-"$date);
return 
$tmp[2] . '-' $tmp[1] . '-' $tmp[0];


$sql = "INSERT INTO table SET date='" . flip_date($_POST['date']) . "'";

And validate the user input.
__________________
One World... Humanetainit | Program secure

Reply With Quote
  #3  
Old June 17th, 2007, 07:20 AM
requinix requinix is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 requinix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 36 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Mysql date formats


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT