Jump to content

[SOLVED] date() increment by 7 days?


Sydcomebak

Recommended Posts

first of all you need to get a current timestamp (which is in seconds) and add the number of seconds to the current timestamp that are in 7 days

 

<?php

$nowtime = time();

$startDate = date("Y-m-d", $nowtime);
$endDate = date("Y-m-d", ($nowtime + (60 * 60 * 24 * 7));

$dateRange = sprinttf(', CompanyStart = "%s", CompanyEnd = "%s"', $startDate, $endDate);

?>

 

That should make your end date 1 week (7 Days) more than the current time.

Link to comment
Share on other sites

This works great for using dates, but what about time?

 

My hosts server is 2 hours ahead of my time zone.  I want to be able to use my PC's time to insert into my form.  I checked both date() and time() but can't find a way to accomplish this.

Link to comment
Share on other sites

Something weird happened today.  Had this in my page

 

$date = date ('Y-m-d');
$backmonth = date("Y-m-d", strtotime("-1 month"));

 

Was working yesterday, now these variables give me this

2008-07-31 
2008-07-01

 

Im guessing its my server thats causing this .... not sure where they are located actually but can anybody explain whats going on?

Link to comment
Share on other sites

Tried doing this

$date = date ('Y-m-d');
$backmonth = date("Y-m-d", strtotime("-2 month"));

 

Gives me this

2008-07-31 
2008-05-31

 

This isn't making sense.  Why does -1 month return 30 days which lies within the same current month, but -2 works fine?

I know my server time is 2hrs ahead of me btw

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.