Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format adding days question

Status
Not open for further replies.

RogueDogg1

Programmer
Jul 13, 2006
11
US
Ok I have this code I found that I think will work with what I need. I need it to add 2 days to the current date.

Code:
<? $newdate  = mktime(0, 0, 0, date("m")  , date("d")+2, date("Y")); ?>

<? echo "$newdate"; ?>

But it's echo'ing this: 1152939600 <-- makes no sense
What am I missing here? Formatting maybe?
 
Here's an alternative way:

1. Use the UNIX timestamp and add 60*60*24*2, i.e. 60 seconds * 60 minutes * 24 hours * 2 days
2. And then, this is what you missed, use the date() function to properly format the timestamp for human consumption.

You did essentially the right thing, 1152939600 translates to Saturday, July 15th 2006, 5:00:00 (GMT). All you need is formatting.
 
I know I'm missing something here, I can't get my brain around the formatting...maybe it's the 1152939600 that's throwing me off.

I tried date(m d,Y) but that does today's date.
I tried date(F j, Y) but that does the current date.

I'm kind lost here... This is all new to me, as you can probably tell I'm a noobie here struggling to learn this complex language. I do appreciate all the help I get however. I have learned alot today, maybe I'm at my daily capacity :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top