$today=date("F j, Y, g:i a");// October 30, 2019, 10:42 pm$today=date("D M j G:i:s T Y");// Wed Oct 30 22:42:18 UTC 2019$today=date("Y-m-d H:i:s");// 2019-10-30 22:42:18(MySQL DATETIME format)
# Current datedate_default_timezone_set('Asia/Kolkata');echodate("Y-m-d H:i:s");# Current Timedate_default_timezone_set("America/New_York");echo"The time is ".date("h:i:sa");
phpCopy<?phpdate_default_timezone_set('Europe/Amsterdam');$DateAndTime=date('m-d-Y h:i:s a',time());echo"The current date and time in Amsterdam are $DateAndTime.
";date_default_timezone_set('America/Toronto');$DateAndTime2=date('m-d-Y h:i:s a',time());echo"The current date and time in Toronto are $DateAndTime2.";?>
phpCopy<?php$Object=newDateTime();$Object->setTimezone(newDateTimeZone('Europe/Amsterdam'));$DateAndTime=$Object->format("d-m-Y h:i:s a");echo"The current date and time in Amsterdam are $DateAndTime.
";$Object->setTimezone(newDateTimeZone('America/Toronto'));$DateAndTime=$Object->format("d-m-Y h:i:s a");echo"The current date and time in Toronto are $DateAndTime.";?>