Jump to content

[SOLVED] strtotime()


suttercain

Recommended Posts

What's up, what's up?

 

I am trying to use strtotime to convert a date, gathered from a database, and add 21 days to the date.

 

Example:

 

Date from MySQL record is 2007-01-01 I need it to be echoed to the browser as 2007-01-22.

 

Here is what I have now but it just outputs the database date without adding the 21 days.

 

$requested = date('F jS, Y', strtotime($row['letter_requested'])); //Convert to letter requested date
$sendBy = strtotime($requested, '+21 day');
echo $sendBy;

Link to comment
https://forums.phpfreaks.com/topic/60603-solved-strtotime/
Share on other sites

Hi Wildbug,

 

I think you have the arguments reversed.  Try:  strtotime('+21 day', $requested);

 

I tried the above code and got the following error:

Warning: strtotime() expects parameter 2 to be long, string given in C:\wamp\www\ARB\pio\date.php on line 134

 

Alternatively, why not just select it from the database as you need it in your script?

I am using this single mysql query for numerous areas of the page. I don't want to limit the query string in that fashion.

 

Link to comment
https://forums.phpfreaks.com/topic/60603-solved-strtotime/#findComment-301475
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.