Source Code:
(back to article)
<?php // Create a DateTime object for the current date and time $date = date_create(); echo $date->format('Y-m-d H:i:s'); // Output: 2023-03-02 09:36:42 // Create a DateTime object for a specific date and time $date = date_create('2022-12-31 23:59:59'); echo $date->format('Y-m-d H:i:s'); // Output: 2022-12-31 23:59:59 // Create a DateTime object for a specific date and time in a specific timezone $date = date_create('2022-12-31 23:59:59', new DateTimeZone('America/New_York')); echo $date->format('Y-m-d H:i:s'); // Output: 2022-12-31 23:59:59
Result:
Report an issue