PDA

View Full Version : Please help me with Dating... :(



Limitlis
April 19th, 2007, 04:54 PM
:book: Ok not actually physical dating... but PHP dates.
For some reason I am just not getting it. :upset: I have tried searching over and over.

I am capturing a date from visitors in this format "4/13/2007" or "mm/dd.yyyy".

I am going to need to be able to add anywhere from a few days to several months.

Is it possible to keep the date in this format and still be able to use php's functions with it? Or do i need to convert it first?

I will be using this to set up automated email reminders. So, essentially, when i add the customer to the DB depending on a criteria i will set their next reminder date X number days from the date they provide me.

Thanks in advance. I would appreciate any kind of help.

foodpk
April 19th, 2007, 05:43 PM
The way to handle dates in PHP is to use strtotime( ... ) on a string and that function returns a UNIX timestamp. A UNIX timestamp is basically the number of seconds that have passed since 1970. Then you can do whatever you want with that timestamp (if you want to add one day, just add 86400 to that) and then when you're done you convert it back to a string by using the date( ... ) function.

Limitlis
April 19th, 2007, 06:57 PM
The way to handle dates in PHP is to use strtotime( ... ) on a string and that function returns a UNIX timestamp. A UNIX timestamp is basically the number of seconds that have passed since 1970. Then you can do whatever you want with that timestamp (if you want to add one day, just add 86400 to that) and then when you're done you convert it back to a string by using the date( ... ) function.

Thanks man I'll give it a shot.

darkredz
April 19th, 2007, 08:07 PM
If you are doing dates with Mysql, check out http://www.kirupa.com/forum/showthread.php?p=2109686#post2109686

it's a no brainer.