The strtotime() function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp. The function accepts a string parameter in English which represents the description of date-time. For e.g., “now” refers to the current date in English date-time description.
If you want to use the PHP function strtotime to add or subtract a number of days, weeks, months or years from a date other than the current time, you can do it by passing the second optional parameter to the strtotime() function, or by adding it into the string which defines the time to parse.
Converting datetime strings to a Unix timestampA combination of two PHP functions, the strtotime() and the date() functions, will produce an output like the one shown in the image above. The strtotime() function converts any given date string into a Unix timestamp. It only accepts the date string as a parameter.
$date = Carbon\Carbon::parse($rawDate); well thats it. You'll now have a Carbon instance & you can format the date as you like using Carbon helper functions.
I have this string: "13/10 15:00" and I would like to convert it to timestamp but when I do this:
$timestamp = strtotime("13/10 15:00");
It returns an empty value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With