Hi @Iggys
I had the same problem with the character birthday
Here is what I ended up doing, this converts it to UK/AU date format as well.
This is in python by the way bdate= datetime.datetime.strptime(str(result['birthday']),'%Y-%m-%dT%H:%M:%SZ').strftime('%d/%m/%y %H:%M:%S')
The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’.
Decode the field correctly. The format is a standard ISO 8601 time format.
MySQL (so is many other databases) do not accept it directly, but many languages you would use between API endpoint and database could parse it just fine.
Hey I figured I should respond to this since the issue has since been resolved.
If you’re having this problem all you have to do is run a bit of regex and get rid of the T and the Z in the returned datetime just like Covid Serine said.
Agreed, regex is overkill. The position of the offending T and Z is known, and won’t change since we can see the date format coming from ESI zero pads all of the datetime components. Just use the known indices of the T and Z and replace the T with a space and delete the Z to conform to the MySQL DATETIME format.
Again, you don’t need “positions”. All you need is to correctly parse the input data and correctly present it in the output. Any relevant language you name has methods to parse ISO 8601 datetime format.
Normally a fair statement, but since the OP didn’t specify any language maybe we shouldn’t assume that a “relevant” language is being used. What if he’s a CS undergrad doing a side project in C on a Windows box because its the only language he knows right now?
Of all the languages I use daily, only Windows CMD can’t deal with dates. For C, there’s standard libs that deal in dates and times.
My point being, you can’t apply string transformations to data that is not actually textual. Datetime is not. It only encoded as text, but to decode it properly, you need a lot of care.