Re: strtotime problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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... :-) .

--
Thodoris


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux