Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adjaf's avatar
Level 1

Request Validator for ISOString Date with milliseconds

I'm working with data sent from a React Native App, i have an events table and I want to validate the dates, they're sent as ISOString

Request Example:

{
...
"start_date": "2018-09-18T10:00:00.000Z",
...
}

In my Request Validator the field validator looks like this:

{
...
'start_date' => 'required|date_format:Y-m-d\TH:i:s.u\Z',
...
}

I have tried .u, .v, :v but i keep getting invalid data.

How can I validate the full ISOString as a date_format ?

0 likes
3 replies
Cronix's avatar

.v is proper since it's milliseconds (3 digits).

The problem is the validator uses DateTime::createFromFormat($datestring), which does not accept the v parameter like it does u.

https://github.com/laravel/framework/issues/19445

I think you'll need to make a custom validation rule for that.

Edit: actually this seems to be fixed in php 7.1. What's your php version?

adjaf's avatar
Level 1

I'm working with PHP 7.2, which date_format should i use then so I can receive the milliseconds?

Please or to participate in this conversation.