parse date with nanoseconds
Hi,
I have a date in the following format "2016-10-07T23:59:59.9999999999".
How can I parse this to a valid DateTime instance? seems PHP can only handle a 6 digit microseconds. not a 9 digit nanoseconds.
This should give you a DateTime like object. It uses the DateTimeInterface, which is used by DateTime as well
date_create_immutable('2016-09-26 11:12:13.123456');
Note: You probably need to parse the T our of this all
that has microseconds, mine has nanoseconds which doesn't parse.
I don't know is it right way to do but you can remove last 3 digits from string
that's indeed what i'm doing now! however it doesn't feel solid.
I can't see other solution because php can parse date onty to microsecunds
Maybe you can create helper function with that code so if you in future php will support that you can change only code in that function
Please or to participate in this conversation.