-2

The Code:

$morningstarts = 9;
$eveningends   = 22;
$dst_change = is_dst($month,$day,$year);
$am7=mktime($morningstarts,0,0,$month,$day,$year,is_dst($month,$day,$year,$morningstarts));
$pm7=mktime($eveningends,$eveningends_minutes,0,$month,$day,$year,is_dst($month,$day,$year,$eveningends));

That code was working very fine on PHP 5.6 but in PHP 7.1 I'm facing the following error.

Warning: mktime() expects at most 6 parameters, 7 given in

Please anyone help me out.

Nick
  • 138,499
  • 22
  • 57
  • 95
salman ifrahim
  • 371
  • 3
  • 8

2 Answers2

2

You need to remove the 7th parameter in the call to mktime and set your timezone with date_default_timezone_set, then PHP will deal with daylight savings time for you. e.g.

date_default_timezone_set('Asia/Karachi');
$morningstarts = 9;
$eveningends   = 22;
$am7=mktime($morningstarts,0,0,$month,$day,$year);
$pm7=mktime($eveningends,$eveningends_minutes,0,$month,$day,$year);
Nick
  • 138,499
  • 22
  • 57
  • 95
0
    $timezone = 'America/Chicago';
    $morningstarts = 9;
    $eveningends = 22;
    $am7 = new \DateTime("@" . mktime($morningstarts, 0, 0, $month, $day, $year));
    $pm7 = new \DateTime("@" . mktime($eveningends, $eveningends_minutes, 0, $month, $day, $year));
    $am7->setTimeZone(new \DateTimeZone($timezone));
    $pm7->setTimeZone(new \DateTimeZone($timezone));
TsV
  • 629
  • 4
  • 7