To convert GMT to Samoa Time in JavaScript, you can use the getTimezoneOffset()
method of the Date object to get the time zone offset in minutes based on the user's current local settings.
Then you can apply the Samoa Timezone offset of UTC+13:00 to the current time to get the converted time. Here's an example code snippet:
index.tsx332 chars12 lines
In this example, 780 is added to the timezone offset (in minutes) to convert from GMT to Samoa Time.
Note that the toLocaleString()
method is used to format the Samoa Time as a string using the user's local settings. You can also use other methods to format the date and time as needed.
gistlibby LogSnag