Hi, is it possible to convert “Tuesday” to actual date ? example the date of the day tuesday in this week is 2015-09-1
Thank you in advance.
Hi, is it possible to convert “Tuesday” to actual date ? example the date of the day tuesday in this week is 2015-09-1
Thank you in advance.
I am confuse how to convert tuesday to exact date in this week to get
2015-09-01
use strtotime to get the appropriate week date, then convert that value to a date.
$date = new DateTime(strtotime('next Tuesday'));
echo $date->format('YY-mm-dd');
Thank you for the reply, can I ask what is the ‘next’ ? I didn’t see that in manual.
it works now using this
echo date(‘Y-m-d’, strtotime(‘Tuesday’));
You can also do it this way →
<?php
$myDate = new DateTime("Next Tuesday", new DateTimeZone("America/Detroit"));
echo $myDate->format("Y-m-d") . "<br>\n";
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.