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
https://forums.phpfreaks.com/topic/157625-solved-mktime-to-a-variable/
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 );

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.