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";

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.