Tags
Asked 2 years ago
9 Jun 2021
Views 163
sarah

sarah posted

how to Convert String Timestamp to timestamp in php ?

how to Convert String Timestamp to timestamp in php ?
dilip

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
Post Answer