This afternoon to do a mall station, the use of time-limited seconds to kill the function. Need a JS Select time Plug-in, from the online down a, plug-in is selected to the second, 24-hour system. Need to put
Converted to a 12-hour system. Originally used is the Strtotime function, but found that the 24-hour string in the use of this function converted to a timestamp will be cast to the 12-hour format of the morning, so long as the plug-in to select more than 12 points of time, there will be an error. So, what to do is to convert the 24-hour time into a 12-hour system.
After testing, to the time format, you need to create a DateTime object first. Method is
Then, using
Convert the Date object to the format you want, OK. It is not possible for this function to convert strings directly. That's why I just started to fail.
The specific process is:
Where the start_time parameter of the data array is the string passed over the time format.
Tips: When solving the timestamp problem, the original conversion, also encountered a problem, is to mistakenly set the date parameter to y-m-d h:m:s
Results after uploading, the discovery time has been error. It was later discovered that the minutes were mistakenly set to M, whereas m in date represents the month.
However, when consulting colleagues, colleagues said that the M-parameter in this case
That is, do not show the month, only show when the seconds and minutes with M can be representative of the minute. But after testing, this is not the case. In this case, the conversion of the timestamp will still cause the original error.
So I conclude that M can only be used as a parameter of the month in this function.
The Tips:strtotime function converts time in string format to a timestamp. If you pass in the afternoon, you need to put the morning's information at the end of the day.
Can.
Is there a way to convert a DateTime object to a timestamp? There, I feel that the function format is a bit cumbersome, not try to use.
PHP 24-hour format date converted to 12-hour date