javascript - PHP check if date between two dates -


i have code in php

date_default_timezone_set('asia/jakarta'); $dt         = new datetime('first saturday of month'); $periode1   = $dt->format('y-m-d'); $periode11  = date( "y-m-d", strtotime( "$periode1 +6 day" ) );  $tgl_delivered  = "2015-07-10"; if (($tgl_delivered >= $periode1) && ($tgl_delivered <= $periode11)){ $tanggal_periode="$periode1 | $periode11"; } echo "$tanggal_periode"; 

and result "2015-08-08 | 2015-08-14";

however want result "2015-07-04 | 2015-07-10" whats wrong code??

try code

function gettanggalperiod($tgldelivered) {     $data=explode("-",$tgldelivered);     $periode1 = date('y-m-d',strtotime('first saturday '.date('f o', @mktime(0,0,0, $data[1], 1, $data[0]))));     $periode11 = date('y-m-d',strtotime($periode1.' +6 day'));     if (($tgldelivered >= $periode1) && ($tgldelivered <= $periode11))     {         echo $tanggal_periode="$periode1 | $periode11";     }     else     {         echo 'not ok';     } }  $tgldelivered = date('y-m-d',strtotime("2015-07-10")); // make sure of maintain date format. gettanggalperiod($tgldelivered); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -