Hi,
I want to save the date of 10 days after the current date in my MySQL DB.
For example:
if today is 29/09/2013 I want to save in my db the date: 09/10/2013
How can I do it?
Thanks!
Hi,
I want to save the date of 10 days after the current date in my MySQL DB.
For example:
if today is 29/09/2013 I want to save in my db the date: 09/10/2013
How can I do it?
Thanks!
This is a several step process.
You can get the current time using:
time()
Then you can add 10 days:
time() + 60*60*24*10
Then you can use that value (save it in a variable) in the date function:
date('FORMAT',$savedtime)
Replace "format" with the appropriate format (anything you want, see the php.net manual for more info).
However, in general it's a bad idea to save dates in a human-readable format in a database. Instead, just save the timestamps. Then do whatever you want with them in PHP-- and format them, using date(), when you display them.
Doing math on raw dates is confusing and indirect. But doing math on timestamps is easy.
By the way, if you do happen to need to convert a string/description/text to a timestamp, then you can use:
strtotime()
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
djr33 (09-29-2013)
Bookmarks