Project details: MySQL, NodeJS, Docker (Timezone set as Etc/UTC)
I upgraded an existing NodeJS project to the latest v5.2.1 today and found that APIs using datetime comparisons or resultsets are either broken or values have changed on the frontend as compared to the previous versions.
This is from the v5.2.1 release notes:
## NodeJS - Improve database resultset, format datetime in local datetime string and check for json
A couple of examples with different results in the latest version as compared to the previous versions. The datetime values are being saved with NOW_UTC wappler input.
- An OTP expiry datetime is being saved in the db.
- Previous version: I was comparing the saved value with this condition:
opt_expiry_date > NOW_UTC
- This is not working any more. - Latest version -
otp_expiry_date > NOW
- working.
- On the frontend, I display the last login date and time.
- Previous version: If the user logged in at 2022-10-21 13:15:00 (Australian time), time saved in the db was 2022-10-21 02:15:00 (UTC -11:00 Hours). Then it was correctly displayed as 2022-10-21 13:15:00 (Australian time) on the frontend without any further formatting requirements.
- Latest version: The datetime value displaying on the frontend is 2022-10-21 02:15:00, which is the UTC datetime value from the db. I cannot display the local datetime value as there’s no
toLocalTime()
formatter on the frontend.
These latest changes in the handling of datetime formatting and result sets have completely changed the way we have been working with these fields / values. I will need to look through all the instances of datetime fields in the existing APIs and in the design code to ensure that these are working as were intended before the latest version.
NodeJS date times had already been difficult to understand and master, especially when working with UTC and local values. The latest version has changed the working once again and will potentially break the existing projects that are running APIs and using values according to the previous version.