How to Display the Month, Day of the Month, and Current Time Plus Twelve Hours?
I am looking for help with my PHP code:
$date = date('m/d/Y h:i:s a', time()); echo "The current server timezone is: " . $date; $jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y")); echo(jddayofweek($jd,1));
Currently this outputs:
The current server timezone is: 03/28/2014 01:27:17 pm Friday
I am trying to make this display the current month, day of the month, and the current time plus twelve hours. For example, the output would be:
The current server timezone is: March 28 Friday at 1:27 am Friday
If anyone can help it will be greatly appreciated. Thank you for any help.
In OOP style:
$dateTime = new DateTime('now'); $dateTime->add(new DateInterval('PT12H')); echo $dateTime->format('F j l \a\\t h:i a l');
Or just with DateTime:
$dateTime = new DateTime('+12 hours'); echo $dateTime->format('F j l \a\\t h:i a l');
If you happen to use Ouzo Goodies in your project then Clock looks neat.
Clock::now()->plusHours(12)->format('F j l \a\\t h:i a l');
echo date('F j l \a\\t h:i a l', strtotime('+12 hours'));
It has the day of the week twice as requested. Not sure if you really want that, though.