Re: strtotime problem

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

 




On Oct 8, 2008, at 7:58 AM, 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.

I was just giving that as an option incase it's not already a timestamp :)

I usually convert to timestamps as soon as the dates are given to the application and store them in the database.

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

As an American, I don't see a big issue with that :P But what Stut said is more then likely true... :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx





[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