Jump to content

Defining a datetime 31 days in the future?


woolyg

Recommended Posts

Hi all,

I'm taking information from a form that defines a starting time for an advert, as follows:

 

 

<?php
$start_day = $_POST['ad_start_day'];
$start_month = $_POST['ad_start_month'];
$start_year = $_POST['ad_start_year'];
$ad_start_date = $start_year."-".$start_month."-".$zero.$start_day." "."00:00:00";
?>

 

Now, i'd like to define $ad_end_date to be 31 days after $ad_start_date.. how do I do this?

 

I've looked at mktime() and strtotime() but neither are very clear, and both arent working for me!

 

Cheers,

Woolyg

Link to comment
Share on other sites

Thanks -

 

I ended up using:

 

<?php
$start_day = $_POST['vacancy_start_day'];
$start_month = $_POST['vacancy_start_month'];
$start_year = $_POST['vacancy_start_year'];

$vacancy_start_date = $start_year."-".$start_month."-".$zero.$start_day." "."00:00:00";
$vacancy_end_date = date("Y-m-d H:i:s", strtotime("$vacancy_start_date + 31 days"));
?>

 

- Woolyg

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.