Page 1 of 1

Converting Date

Posted: Sun Mar 25, 2007 7:46 pm
by iknownothing
Hey guys,
I'm just wondering if it were at all possible to convert a formatted date back to a timestamp, (date originally formatted for user friendliness). The user is to enter a date DD/MM/YYYY (the way us Australians write it, not MM/DD/YYYY), is there any way this can be made a timestamp again, doesnt have to be precise to the second, so it can be the correct date, but at 12:00am if it has to be?


Thanks

Posted: Sun Mar 25, 2007 7:57 pm
by volka
explode() and mktime() might be useful

http://de2.php.net/explode
http://de2.php.net/mktime

Posted: Sun Mar 25, 2007 8:22 pm
by iknownothing
mktime() looks like a winner, thanks.

Also, with using mktime(), I've read that blank arguments within mktime() use the current time (eg minutes/seconds).

The reason I asked the original question, is because the user enters in formatted dates From and To, to get all specific entries in between these two dates. If entry "A" was orginally entered using mktime(), but hours minutes and seconds was left blank, would a search between the From and To also include entry "A" if the search was done before the original entry time? Or would it be better practice to set hours, minutes and seconds to a "zero" value (ie. right on Midnight) when entering data, and 11:59pm on the search?

Thanks again.

Posted: Mon Mar 26, 2007 9:15 am
by feyd
The user will likely expect the maximum possible so the "from" would default to zeros, then "to" would default to the maximum for each element.