Is there a function that uses the date()
format to interpret a string?
echo date('s-i-H d:m:Y', 1304591364); // 34-29-17 05:05:2011
// Does this function exist?
echo inverse_date('s-i-H d:m:Y', '34-29-17 05:05:2011'); // 1304591364
I know strtotime()
, but it’s failing me in most cases as I am not parsing English date formats.
I’m looking for a function that can dictate the format.
PHP date() Function The PHP date function is used to format a date or time into a human readable format. It can be used to display the date of article was published. record the last updated a data in a database.
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
echo "Today is " . date("Y.m.d") . "<br>"; echo "Today is " .
Answer: Use the PHP date() Function You can simply use the PHP date() function to get the current data and time in various format, for example, date('d-m-y h:i:s') , date('d/m/y H:i:s') , and so on.
PHP 5.4+ will print 1359674625
echo date_create_from_format('j/n/Y G:i:s','1/2/2013 1:23:45')->getTimestamp();
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