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)
1echo date('Y-m-d H:i:s');
2
3//Output something like this:
4//2021-07-30 10:07:45
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
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