i wana get date of saturday of current week with date of current day,how its possible,im googling but nothing found,
Assuming that you have the original date in $dt and want Saturday’s date in $dt1 then we can do:
$dt1 = DateTime::createFromFormat(('Y-m-d', date('Y-m-',$dt).(6+date('j',$dt)-date('w',$dt)));
thanks but what is the format of $dt?
when i run this code $dt=date("d"); $dt1 = DateTime::createFromFormat(('Y-m-d',date('Y-m-',$dt).(6+date('j',$dt)-date('w',$dt))); echo $dt1;
i get this error Parse error: syntax error, unexpected ',' in ...
this error belongs to line of $dt1 = DateTime::createFromFormat(('Y-m-d', date('Y-m-',$dt).(6+date('j',$dt)-date('w',$dt)));
i think i maked a mistake,the format of $dt?
$dt would be a date object.
i have same parse error,Parse error: syntax error, unexpected ‘,’ in …
`$dt = new DateTime(‘02/31/2011’);
$dt1 = DateTime::createFromFormat((‘Y-m-d’,date(‘Y-m-’,$dt).(6+date(‘j’,$dt)-date(‘w’,$dt)));
echo $dt1;`
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.