Converting Date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Converting Date

Post 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
Last edited by iknownothing on Sun Mar 25, 2007 8:24 pm, edited 2 times in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

explode() and mktime() might be useful

http://de2.php.net/explode
http://de2.php.net/mktime
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply