One of our EDI customers sent in orders with the w...
# suitescript
e
One of our EDI customers sent in orders with the wrong year (2022) instead of the current year (2021) and we need to fix those dates by basically just changing the year to the current year. I've tried several approaches but all of them including using moment with the adddays option resulted in ending up with the prior day for the date (ie 07/22/2022 ends up being 07/21/2021). I tried this method but it still ends up doing the same exact thing. -- var date2 = new Date(new Date(shipDate).setFullYear(new Date(shipDate).getFullYear() - 1));
b
i would expect that code to only work perfectly when the script's user uses the pacific time zone
anything else with offsets in the future should be wrong
e
So are you saying that the original date/time stamp is using a different time zone so that when I convert the date (our instance is in the Pacific Time Zone), it results in being a day different?
b
new Date(shipDate)
is only correct if the timezone of the user is pacific
the timezone of the server is always pacific
but the user of the script may not be
e
the mass update script is set to use current user which is me and I’m in the Pacific Time Zone.
b
log the timezone using User.getPreference
you might as well get the date format too
e
Thanks I ended up doing a CSV import instead.