Why won't PHP strtotime work for a date in this format mdy? -


I have a problem verifying the dates in PHP 5.2.17 I would like to enter a six-digit date without any punctuation marks The user needs to, so will be 15 January 2014 011514. (This is due to the limit of input device and user convenience).

Tested and it is not working:

  $ testDate = "011514"; $ myDate = date ('MDI', Stratom ($ testdate)); Echo $ myDate;   

I expected that my date is similar to the date of examination, but it is not, it prints today's date 042314 (April 23, 2014)! PHP does not like that there is no punctuation in my original string. If I change $ testDate = "01-15-14" then the PHP excludes the correct string "011514".

How can I understand strtotime () that I want to check dates in 'mdy' format without using date_create_from_format?

Additional information: The PHP version is 5.2.17, so is not able to use date_create_from_format.

What is the limit of stratetime () can understand. It can not understand everything, this is the reason why they tell us what it does and we, as developers, need to write our code in a way that respects it.

You need to do this in your code, insert the slash and you have all the sets. $ testDate = "011514"; $ Date = sprintf ('% s /% s /% s', subtracut ($ testdate, 0, 2), substitact ($ testdate, 2, 2), substitact ($ testdate, 4, 2)); $ myDate = Date ('MDI', Stratown ($ date)); Echo $ myDate;



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -