current date in php : Using date() Function & Using DateTime() Class to get current Date & Time in PHP. The main focus of the post is to get the current Date and Time in PHP.
current date in php – How to Get Current Date and Time in PHP?
Solution PHP date: Use the PHP date() Function with Set the new timezone.
Using date() Function
Example : 1
Results
2022-02-25 08:22:26
More examples
date('Y/m/d'); // 2022/02/25 date('m/d/Y'); // 02/25/2022 date('H:i:s'); // 08:22:26 date('Y-m-d H:i:s'); // 2022-02-25 08:22:26
Using DateTime() Class:
Example
format('Y-m-d H:i:s'); ?>
Results
2022-02-25 08:22:26
don’t Miss : Get current time in PHP
How to Get the Current Date and Time in PHP?
Set the new timezone
Return current date from the remote server
$created_at = date('d-m-y h:i:s'); echo $created_at; ?>
I hope you get an idea about current date in php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.