'php:Y-m-d\TH:"> Format date string-PHP Chinese Network Q&A
Format date string
P粉680087550
P粉680087550 2023-08-18 12:54:30
0
1
404

I have this string "0001-01-01T00:00:00.0000000 01:00".

I tried creating a validation rule similar to Y-m-dTH:i:s.uP, but it failed. What is the correct format of this string?

public function rules() { return [ [ ['requested_delivery_date'],'datetime', 'format' => 'php: Y-m-dTH:i:s.uP' ], ]; }

P粉680087550
P粉680087550

reply all (1)
P粉739706089

According to the time string0001-01-01T00:00:00.0000000 01:00, the possible date formats are as follows:

  • "0001-01-01"is the date formatYYYY-MM-DD
  • Tcan be used as a separator between date and time
  • 00:00:00.0000000 indicates the time format is HH:II:SS:sssssss
  • 01:00 may be the time zone

I'm not sure if the regex will validate it correctly. So, it will be better if you use custom function to validate this date format. Or validate the date, time and time zone separately and concatenate them in your format when saving to the database.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!