![]() |
VOOZH | about |
To get the current date and time in PHP, use the date() function, which formats UNIX timestamps into a human-readable format. It converts timestamps, measured in seconds since January 1, 1970, into a more understandable representation for users.
Syntax:
date('d-m-y h:i:s');Parameters: The date() has different parameters. Each parameter represents some meaningful unit.
Example 1: In this example we displays the current date and time by storing it in the $myDate variable using the date() function and then printing it in the format day-month-year hours:minutes:seconds.
Output:
Current date and time is :03-01-21 04:49:52Example 2: The following demonstrates other date() functions format which can be used by the developer as per the need.
Output:
👁 Image