Jump to content

[SOLVED] mktime to a variable


bschultz

Recommended Posts

I can't seem to find any documentation on how to apply mktime to a variable.  I have a url that will pass a date in the format of:  xxxx-x-x

 

I need to take that date, and find the previous month to that variable.

 

Since I couldn't find any documentation on how to apply it to a variable, I tried this...which didn't work.

 

$day = $_GET['day'];
$previousmonth = "$day mktime(0, 0, 0, date('m')-1)";

 

How is this supposed to be done? 

 

Thanks.

Link to comment
Share on other sites

I get an "invalid day" error on this code

 

$day = $_GET['day'];

$data = "$day";
list($year, $month, $date) = explode("-", $data);	

$previousmonth = ($month - 1);

$thisyear = date("Y");
    
    // find out the number of days in the month
    $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $previousmonth, $thisyear );

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.