Jump to content

[SOLVED] strtotime Help. Pretty Easy, I'm sure.


Clinton

Recommended Posts

$cdlmedical is a date in my database. I have one row currently and the date in there is 4-4-2007.

 

When I try to add 11 months to it and output it I am getting the default time 12/31/1969.

 

Where am I going wrong?

 


while ($row=mysql_fetch_assoc($result)){ extract($row);

echo "$cdlmedical <br />";

$cdlmedical = date('$cdlmedical',strtotime('+ 11 months'));

$cdlmedical = date('n/j/Y',strtotime($cdlmedical));

echo "$lname $cdlmedical";

}

Thanks Guy.

 

And Ken, I did look at the manual. I even looked multiple places. That's how I was able to attempt putting that whole contraption together. I couldn't figure out why it wasn't working so I posted here for help. Thought I was allowed to do that.

because you are using single quotes, and anything in single quotes will be read as text

 

double quotes it will be read as a dynamic string.

 

<?php
$cdlmedical = strtotime($cdlmedical.' + 11 months');
// is the same as:
$cdlmedical = strtotime("$cdlmedical + 11 months");
?>

 

is that what your asking?

I did look at the manual. I even looked multiple places. That's how I was able to attempt putting that whole contraption together. I couldn't figure out why it wasn't working so I posted here for help. Thought I was allowed to do that.

Yes, you're allowed to do that, but when I looked at you code snippet it didn't look like you had seen the manual at all.

 

The '.' is the concatenation operator.

 

Ken

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.