Jump to content

Incrementing an entered date


newburcj

Recommended Posts

I have a form with two text fields:

Date the show will open: $_POST['vdate'] (not the current date)

and

Number of performances: $_POST['shows']

 

vdate is entered in the format 'yyyy-mm-dd'.

 

I would like to take the original vdate, enter its value into a MySQL field, and increment the date by one day in a loop until the value of shows is reached. The loop isn't my problem. I can't seem to increment the date within the loop. There's a lot of date functions within php but none of them seem to be able to do this simple addition: newdate = date + 1 day. Help would be appreciated as I'm totally stuck.

 

Thanks!

Link to comment
Share on other sites

I finally figured out the code needed:

 

<?php

$TZ = date_default_timezone_set("America/New_York"); \\ if not already set.

$oldate = '2010-05-10';

$dd = strtotime($oldate) + 86400;

$newdate =  date("Y-m-d",$dd);  \\ newdate becomes '2010-05-11'

?

 

Thanks! ;D

Link to comment
Share on other sites

I finally figured out the code needed:

 

<?php

$TZ = date_default_timezone_set("America/New_York"); \\ if not already set.

$oldate = '2010-05-10';

$dd = strtotime($oldate) + 86400;

$newdate =  date("Y-m-d",$dd);  \\ newdate becomes '2010-05-11'

?

 

Thanks! ;D

 

$newdate = strtotime('2010-05-10' . " +1 days");

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.