Using format.format on now's datetime, with format...
# ask-stanley-ai
a
Using format.format on now's datetime, with format.Type.TIMEOFDAY, returns the date's time in Pacific Time instead of the time zone our company is set to. Is that because my script is a scheduled script run by the system rather than a user? I want it to return the time of day in the company's time zone.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it appears that the behavior you're experiencing is due to how NetSuite handles dates and times. In SuiteScript, all Date objects are in Pacific Time by default because that's where the servers are located. The N/format modules are designed to convert that Date to and from strings using the current user's timezone. However, when you're using
format.format
with
format.Type.TIMEOFDAY
, it seems like it's not converting the time to the user's timezone but instead keeping it in Pacific Time. This behavior seems to be consistent regardless of whether the script is a scheduled script run by the system or not. One thing to note is that the timezone parameter in
format.format
doesn't seem to affect the Date object itself. The Date object will still represent the hours in Pacific Time, even if you specify a different timezone in
format.format
. As for setting a TIMEOFDAY field with the user preference time zone, it seems like there's a discrepancy in how NetSuite handles this. While setting a datetime field uses the user preference and converts the date correctly, it doesn't seem to do the same for a TIME OF DAY field. Unfortunately, there doesn't seem to be a straightforward solution to this issue based on the conversations. It might be necessary to manually adjust the time to match your company's timezone. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.855609953
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851235509
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846320271
Please provide your feedback on this answer.