Thodoris wrote:
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:
Of course this means that I will explode the date anyway so I will not
need the intermediate transformation into timestamp.
<?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?
Actually this means that strtotime() was made with Americans *only* in
mind... :-) .
From your function name I assume you want to use it in MySQL. In that
case, why don't you have MySQL do all the magic for you?
eg. INSERT INTO table (col) VALUES (FROM_UNIXTIME($timestamp));
(using FROM_UNIXTIME($timestamp) will give you the date-time in "mysql
format" (YYYY-MM-DD HH:MM:SS) or any other format (if given via the 2nd
parameter)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php