note 38911 deleted from function.strtotime by tomsommer
| From: | tomsommer@php.net | Date: | Sun, 11 Jan 2004 23:03:38 +0000 |
| Subject: | note 38911 deleted from function.strtotime by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63330@lists.php.net to get a copy of this message | ||
Note Submitter: siarsky@usa.com
----
Do you know SimpleDateFormat from Java? I was missing this class a lot,
so I wrote a PHP version:
include_once 'SimpleDateFormat.php';
$input_format = new SimpleDateFormat('dd.MM.yyyy HH:mm:ss'); //Europe standard
$output_format = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss'); //mySql standard
$input_date = '29.2.2000 14:33:57';
$date = $input_format->parse($input_date);
if ($date != ""){
//date is valid
$output_date = $output_format->format($date);
}
else {
//date is invalid
}
For more see http://www.siarsky.ch/php/SimpleDateFormat.html