Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UK and Mysql date format

Status
Not open for further replies.
Jul 28, 2005
358
FR
Hi,

I have a database that stores dates using the mysql date/time field type. I want to be able to enter UK style dates (eg 29/07/05 for 29th July 2005) and have them convert into the same format as the mysql date/time field (eg 2005-05-29 00:00:00) for entering into the database.

Is there an easy way to do this? I use the mysql now() function to check dates to see if they have expired and need to be able to use UK style dates.

Thanks

Richard
 
you didnt say how you was accesing the database. e.g. are you using php. a pre-bilt program, if php then one way would be to convert to timestamp and then put that into the database

Binary Intelligence, true or false?
 
Sorry, using php,

A date is entered into the form using the format 29/07/2005 and needs to be held in the mysql as a date (I validate later using the now() mysql value) so it needs to be held as a proper mysql date.

Richard
 
PHP has the very handy function strtotime().
PHPmanual said:
strtotime -- Parse about any English textual datetime description into a Unix timestamp

You can 'trnaslate' to a MySQL date combining date(0 and strtotime:
Code:
date('m/d/Y',strtotime('29/07/2005'))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top