I haven’t used NodeJS yet, but I imagine the timezone settings are set in different places for PHP and NodeJS. Eg if the timezone is set in php.ini, I don’t suppose NodeJS is going to use that value.
That is what it looks like. I think that I will not be the only one who wants to recreate a site in NodeJS and it would be great if the different platforms would behave the same without having to change the Server Action.
We don’t have a formatter that supports microseconds. What is the exact output that you require, perhaps I can help you by making a custom formatter for it.
The problem is that I have a query on a MySQL Database (Linux Server) and a MS SQL Database (Windows Server). Newer entries from the MS SQL Database are inserted in the MySQL Database. With NodeJS the query to check the last inserted entry does not work correct because of the wrong timezone. The inserted dates are also wrong.
Could you give advice what would be the best approach to solve this?
The driver used in nodeJS returns all datetimes in utc, I can’t change that behavior. But even with conversion it is possible to have different timestamps, it depends on how your server is configured. Which timezone is configured in PHP, MSSQL, MySQL and on the server. If they have different timezones configured it could be difficult to fix. It probably will need some manual correction by using the DateAdd formatter to fix the date.
I could make a formatter to go from local time to utc and back. The timezone depends on the system timezone with nodeJS and with PHP it depends on the timezone set in the php.ini.
Updated the date/time formatters for nodeJS, you may try them out.
util.zip (1.3 KB) This has an updated formatDate function that has support for milliseconds. Place it in lib/core.
date.zip (836 Bytes) This has two new formatters, toLocalTime() and toUTCTime() which can be used to convert date string to local/utc strings. Place it in lib/formatters.
Usage of formatDate with miliseconds, following will return exact the same as toLocalTime() formatter: