1$today = date("F j, Y, g:i a"); // October 30, 2019, 10:42 pm
2$today = date("D M j G:i:s T Y"); // Wed Oct 30 22:42:18 UTC 2019
3$today = date("Y-m-d H:i:s"); // 2019-10-30 22:42:18(MySQL DATETIME format)
1date_default_timezone_set('Asia/Kolkata');
2echo date("Y-m-d H:i:s"); // time in India
1phpCopy<?php
2$Object = new DateTime();
3$DateAndTime = $Object->format("d-m-Y h:i:s a");
4echo "The current date and time are $DateAndTime.";
5?>
6
1phpCopy<?php
2$DateAndTime = date('m-d-Y h:i:s a', time());
3echo "The current date and time are $DateAndTime.";
4?>
5
1phpCopy<?php
2date_default_timezone_set('Europe/Amsterdam');
3$DateAndTime = date('m-d-Y h:i:s a', time());
4echo "The current date and time in Amsterdam are $DateAndTime.\n";
5date_default_timezone_set('America/Toronto');
6$DateAndTime2 = date('m-d-Y h:i:s a', time());
7echo "The current date and time in Toronto are $DateAndTime2.";
8?>
9
1phpCopy<?php
2$Object = new DateTime();
3$Object->setTimezone(new DateTimeZone('Europe/Amsterdam'));
4$DateAndTime = $Object->format("d-m-Y h:i:s a");
5echo "The current date and time in Amsterdam are $DateAndTime.\n";
6$Object->setTimezone(new DateTimeZone('America/Toronto'));
7$DateAndTime = $Object->format("d-m-Y h:i:s a");
8echo "The current date and time in Toronto are $DateAndTime.";
9?>
10