mktime()
` function :<?php
// create a date and time from a number of parameters
$hour = 12;
$minute = 30;
$second = 45;
$month = 5;
$day = 1;
$year = 2023;
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
// output the timestamp
echo "Timestamp: $timestamp<br>";
// convert timestamp to a date string
$date = date('Y-m-d H:i:s', $timestamp);
// output the date string
echo "Date: $date";
?>
Timestamp: 1682944245
Date: 2023-05-01 12:30:45
mktime()
` function to create a timestamp from these parameters. echo
` statement. Then, we use the `date()
` function to convert the timestamp to a human-readable date string. We format the date string to display the year, month, day, hour, minute, and second, separated by hyphens and colons, using the format `'Y-m-d H:i:s
'`. echo
` statement.