You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a "local dateTime" string under the YYYY-MM-DDTHH:mm format.
I need to create a Date object from this string, assuming it is relative to a specific timezone.
Here are some examples that illustrate what I'm trying to achieve:
functioncreateDate(localDateTime: string,timezone: string): Date{// ???}/* Examples */conststr1="2024-01-25T11:00";conststr2="2024-05-25T11:00";createDate(str1,"Europe/Brussels");// -> Thu Jan 25 2024 11:00:00 GMT+0100 (Central European Standard Time) createDate(str2,"Europe/Brussels");// -> Sat May 25 2024 11:00:00 GMT+0200 (Central European Summer Time)createDate(str1,"Asia/Singapore")// -> Thu Jan 25 2024 11:00:00 GMT+0800 (Singapore Standard Time)createDate(str2,"Asia/Singapore");// -> Sat May 25 2024 11:00:00 GMT+0800 (Singapore Standard Time)
How can I implement createDate using date-fns 3.0.0 APIs ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a "local dateTime" string under the
YYYY-MM-DDTHH:mm
format.I need to create a
Date
object from this string, assuming it is relative to a specific timezone.Here are some examples that illustrate what I'm trying to achieve:
How can I implement
createDate
usingdate-fns
3.0.0 APIs ?Beta Was this translation helpful? Give feedback.
All reactions