PHP Script To Find and Print The Current Date And Time

www.lautt‮c.iru‬om
PHP Script To Find and Print The Current Date And Time

To find and print the current date and time in a PHP script, you can use the date function with a format string that specifies the format of the date and time.

For example, to print the current date and time in the format "Year-Month-Day Hour:Minute:Second", you can use the following PHP code:

<?php
  $current_date_time = date('Y-m-d H:i:s');
  echo "The current date and time is: $current_date_time";
?>

This will print the current date and time in the specified format.

You can find more information about the date function and its options in the PHP documentation or by running the php --help command.

Note: The date and time displayed by the date function depend on the time zone setting of your server. You can use the date_default_timezone_set function to set the time zone for your PHP script. For example:

<?php
  date_default_timezone_set('America/New_York');
  $current_date_time = date('Y-m-d H:i:s');
  echo "The current date and time is: $current_date_time";
?>

This will set the time zone to "America/New_York" and print the current date and time in that time zone.

Created Time:2017-10-30 14:27:08  Author:lautturi