Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP have an inverse of the date() function (other than strtotime())?

Tags:

date

php

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.

like image 708
Moak Avatar asked May 05 '11 09:05

Moak


People also ask

What does Date () do in PHP?

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.

What is the use of Strtotime function in PHP?

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.

How can I get current date in YMD in PHP?

echo "Today is " . date("Y.m.d") . "<br>"; echo "Today is " .

How can get current date and day in PHP?

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.


1 Answers

PHP 5.4+ will print 1359674625

echo date_create_from_format('j/n/Y G:i:s','1/2/2013 1:23:45')->getTimestamp();
like image 104
mu3 Avatar answered Sep 19 '22 20:09

mu3