How to Get Date and Time In PHP?

PHP

Nicesnippets

300

16-12-2020


Hi Guys,

In this example,I will learn you how to get current time and date in php. you can easy and simply get yo time and date in php.

Example 1:


<?php

$today = date('Y-m-d H:i:s');

echo($today);

?>

Output:

2020-12-16 10:37:49

Example 2:

<?php

$today = date("F j, Y, g:i a");

echo($today);

?>

Output:

December 16, 2020, 10:37 am

Example 3:

<?php

$today = date("j, n, Y");

echo($today);

?>

Output:

16, 12, 2020

Example 4:

<?php

$today = date("D M j G:i:s T Y");

echo($today);

?>

Output:

Wed Dec 16 10:35:55 IST 2020

Example 5:

<?php

$today = date("l M j G:i:s T Y");

echo($today);

?>

Output:

Wednesday Dec 16 11:05:18 IST 2020

It will help you...