Learn Codeigniter

Get Current Date and Time In PHP

To get Current Date and Time we will use following PHP code.

Example

<?php
date_default_timezone_set('America/Los_Angeles');
echo $currentDate="Curret Date: ".date('d-m-Y')."<br>";
echo $currentTime="Curret Time: ".date('H:i:s');
?>

Output

Curret Date: 01-01-2015 Curret Time: 05:59:47

Note: Change timezone according to you.