On Oct 8, 2008, at 7:24 AM, Thodoris wrote:
On Oct 8, 2008, at 7:08 AM, Thodoris wrote:
I know that *strtotime*() only recognises the formats mm/dd/yyyy,
yyyy-mm-dd and yyyymmdd
****for numeric months but I need do something like that:
function dateWebToMysql($webdate){
$format = 'Y-m-d';
$timestamp = strtotime($webdate);
return date($format,$timestamp);
}
print dateWebToMysql('01/03/2008');
Where 01/03/2008 is in dd/mm/yyyy format (not the American
format). What is the best way of doing this?
Any ideas?
Actually strtotime accepts all kinds of things... "Last week
Thursday midnight" for example works perfectly.
You could do an explode on the field and then reorder the array
anyway that you want...
<?PHP
$date = "13/01/2008";
$datearray = explode("/", $date);
echo $datearray[1] ."/". $datearray[0] . "/" . $datearray[2];
?>
Or something like that :)
That wasn't tested but should give you an idea...
php.net/explode for more info.
This is what I was doing before (which is a bit lame) so I am
looking for a more elegant way using timestamps.
Well, If it's not already a timestamp, you can use mktime() to make it
one, once it is then you should just be able to:
<?PHP
$timestamp ="1222354037";
echo date("d/m/y h:i:s", $timestamp);
?>
to format and display it. I'm using that on a time card application
right now and it's working great.
Is that more what you are looking for?
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php