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
Describe the bug
The moment().locale() function is not able to override the locale from 'ja' to 'en' for a specific instance. As a result, it's not able to correctly parse the "AM/PM" part of a UTC date-time string. ex: '5/11/2024 3:00:31 PM'
To Reproduce
Steps to reproduce the behavior:
Set the global locale to 'ja' using moment.locale('ja').
Try to parse a date-time string in English format with the "AM/PM" part, using moment().locale('en').
ex:moment("5/11/2024 3:00:31 PM", "M/D/YYYY h:mm:ss a").locale('en').utcOffset(0, true).unix()
The "AM/PM" part is not parsed correctly, as indicated by unusedInput:["PM"] and unusedTokens: ["a"].
Expected behavior
The moment().locale('en') function should override the global locale for the specific instance, allowing the "AM/PM" part of the date-time string to be parsed correctly. 1715439631 -> Saturday, 11 May 2024 15:00:31
Wrong behavior 1715396431 -> Saturday, 11 May 2024 03:00:31
Desktop (please complete the following information):
OS: macOS 14.4.1 (23E224)
Node.js version: v16.20.2
Moment.js version: 2.30.1
Moment-specific environment
The time zone setting of the machine the code is running on: [e.g. JST]
The time and date at which the code was run: [e.g. '5/10/2024 8:58:17 PM']
Other libraries in use: moment-duration-format 2.3.2, moment-timezone 0.5.34
Please run the following code in your environment and include the output:
console.log((newDate()).toString())//'Thu May 16 2024 01:28:31 GMT+0530 (India Standard Time)'console.log((newDate()).toLocaleString())//'16/05/2024, 01:28:47'console.log((newDate()).getTimezoneOffset())//-330console.log(process.version)console.log(moment.version)//'2.30.1'
The text was updated successfully, but these errors were encountered:
Describe the bug
The
moment().locale()
function is not able to override the locale from 'ja' to 'en' for a specific instance. As a result, it's not able to correctly parse the "AM/PM" part of a UTC date-time string. ex: '5/11/2024 3:00:31 PM'To Reproduce
Steps to reproduce the behavior:
moment.locale('ja')
.moment().locale('en')
.ex:
moment("5/11/2024 3:00:31 PM", "M/D/YYYY h:mm:ss a").locale('en').utcOffset(0, true).unix()
unusedInput:["PM"]
andunusedTokens: ["a"]
.Expected behavior
The
moment().locale('en')
function should override the global locale for the specific instance, allowing the "AM/PM" part of the date-time string to be parsed correctly.1715439631
->Saturday, 11 May 2024 15:00:31
Wrong behavior
1715396431
->Saturday, 11 May 2024 03:00:31
Desktop (please complete the following information):
Moment-specific environment
Please run the following code in your environment and include the output:
The text was updated successfully, but these errors were encountered: