dilip
answered Apr 26 '23 00:00
To convert a string timestamp to a timestamp in PHP, you can use the strtotime () function, which converts a string representation of a date and time to a Unix timestamp.
Here's an example:
$string_timestamp = '2022-05-01 12:30:00';
$timestamp = strtotime($string_timestamp);
echo $timestamp; // output: 1651445400
In this example, the $ string_timestamp variable holds the string representation of the timestamp in the format 'YYYY-MM-DD HH:MM:SS'. The strtotime () function converts this string to a Unix timestamp, which is assigned to the $ timestamp variable. Finally, the echo statement outputs the Unix timestamp