[PHP-DB] Re: Date Conversion

2004-08-18 Thread Torsten Roehr
Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi all,

can someone kindly point me to a resource that converts all kinds of
possible date inputs into MySQL format of -MM-DD?

example of formats to be converted includes:

d/m/yy
d/m/
d/mm/yy
d/mm/yyy
dd/mm/yy
dd/mm/yyy
d/mmm/yy
d/mmm/
dd/mmm/yy
dd/mmm/

yy   - 2 digit representation of year
   - ful numeric representation of year
m   - numeric representation of month, without leading zero
mm- numeric representation of month, with leading zero
mmm - short textual representation of month
d   - day of month without leading zero
dd - day of month with leadin zero

thanx!

hwee

This question belongs more to the general list, but anyway:

You can use strtotime() to convert various formats to a timestamp. Then use
date() to convert it back to your preferred date format:

$timestamp = strtotime($inputDate);
$isoDate   = date('Y-m-d', $timestamp);

http://de2.php.net/strtotime
http://de2.php.net/manual/en/function.date.php

Regards, Torsten Roehr

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Date Conversion

2004-08-18 Thread Paul
You might want to look into date conversion on the MySQL side:

http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

Look for 

DATE_FORMAT(date,format)

Paul


On Wed, 18 Aug 2004 10:16:59 +0200, Torsten Roehr [EMAIL PROTECTED] wrote:
 Ng Hwee Hwee [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
 Hi all,
 
 can someone kindly point me to a resource that converts all kinds of
 possible date inputs into MySQL format of -MM-DD?
 
 example of formats to be converted includes:
 
 d/m/yy
 d/m/
 d/mm/yy
 d/mm/yyy
 dd/mm/yy
 dd/mm/yyy
 d/mmm/yy
 d/mmm/
 dd/mmm/yy
 dd/mmm/
 
 yy   - 2 digit representation of year
    - ful numeric representation of year
 m   - numeric representation of month, without leading zero
 mm- numeric representation of month, with leading zero
 mmm - short textual representation of month
 d   - day of month without leading zero
 dd - day of month with leadin zero
 
 thanx!
 
 hwee
 
 This question belongs more to the general list, but anyway:
 
 You can use strtotime() to convert various formats to a timestamp. Then use
 date() to convert it back to your preferred date format:
 
 $timestamp = strtotime($inputDate);
 $isoDate   = date('Y-m-d', $timestamp);
 
 http://de2.php.net/strtotime
 http://de2.php.net/manual/en/function.date.php
 
 Regards, Torsten Roehr
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php