Jump to content

Date() Php And Mysql


rmpotter

Recommended Posts

I am looking for a simple way to save a date to MYSQL and then later extract it and add 60 days on to it. I am unsure the best format to save the date as for later extraction, currently I am using SQLs curdate() but feel using PHPs Date() may be easier to add time. Any ideas?

Link to comment
Share on other sites

It's best to save the integer timestamp that you get from the time() function. That will return the number of seconds since 1/1/70, so if you want to add 60 days you just add 60 days worth of seconds. A day has 86400 seconds. You can convert the timestamp back to a readable format with the date function, or you can get the timestamp for a specific date with the mktime function.

Link to comment
Share on other sites

It's best to save the integer timestamp that you get from the time() function. That will return the number of seconds since 1/1/70, so if you want to add 60 days you just add 60 days worth of seconds. A day has 86400 seconds. You can convert the timestamp back to a readable format with the date function, or you can get the timestamp for a specific date with the mktime function.
thanks, i'll give it a try
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...