How do get current date and time in PHP?

User avatar
RachelPeene
Posts: 6
Joined: Sat Oct 01, 2016 12:13 pm

How do get current date and time in PHP?

Fri Mar 29, 2019 4:03 am

This can be more reliable than simply adding or subtracting the number of seconds in a day or a month to a timestamp because of daylight saving time.

The PHP code Below:
/ Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i A"); // March 29, 2019, 5:16 pm
$today = date("m.d.y"); // 03.29.19
$today = date("j, n, Y"); // 29, 3, 2019
$today = date("Ymd"); // 20190329
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 29 19:16:18 MST 2001
$today = date('H: m : s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2019-03-29 17:16:18 (the MySQL DATETIME format)
<? echo $today = date("F j, Y, g:i A"); ?>
result,
March 29, 2019, 5:16PM


Return to “WEB DESIGN, PHP, HTML”

Links

In total there are 4 users online :: 1 registered, 0 hidden and 3 guests
Registered users: Bing [Bot]
Most users ever online was 33 on Sat Mar 09, 2019 8:21 pm
Total posts 489
Total topics 371
Total members 70
Our newest member Mirasoida
No birthdays today