Hi all, i have an issue with date time, i hope som...
# suitescript
d
Hi all, i have an issue with date time, i hope someone can help i have
custbody_my_updated_at
, type = date/time, the value is 14 March 2022 100000 am applied in sales order in my scheduled script, after i load the record, i do
salesorder.getValue({fieldId: 'custbody_my_updated_at'})
, the result is 14 March 2022 030000 am My company and user preference is using timezone Asia/Bangkok, GMT +7 How to get 14 March 2022 100000 am from my scheduled script ?
b
answering the question usually involves understanding the difference between a Date and a string
javascript Dates represent a difference in milliseconds
for example, that difference right now is about 1647257068263
14 March 2022 6:25 pm is one of the many strings that correspond to that particular unix time
equally valid is Mon Mar 14 2022 042654 GMT-0700 (Pacific Daylight Time)
with this one being more useful since it states the timezone
14 March 2022 100000 am is only useful with the timezone information given
in your case, its GMT +7
which probably means 14 March 2022 030000 am is GMT+0
which is the same unix time as the first datetime string you gave
if you were looking for a Date, both strings are representations of the same Date
d
thanks for your lengthy explanation @battk yes you're right the value that i get is 14 March 2022 030000 am GMT+0, but in the UI it shows as GMT+7
i want to get the value same as what's showing in the UI
i was thinking to add 7 hours from the the value i get using getValue()
not sure if it's good approach
b
if you actually wanted a Date, you want to leave it as is
if you want a string, you can use getText
if you really want to work with it in a different timezone, then you want to use moment timezone
d
ok battk, thanks for you explanation