Skip to content

bug report: moment.tz format has some bug , unexpected year number 0002 #1115

@Zola

Description

@Zola

Environment

For bug reports, please run the following code in your environment and include the output:

console.log({
  moment: moment.version,
  momentTz: moment.tz.version,
  date: (new Date()).toString(),
  intlZone: new Intl.DateTimeFormat().resolvedOptions().timeZone,
});

{moment: "2.29.1", momentTz: "0.5.34", date: "Sun Aug 04 2024 03:28:32 GMT+0800 (台北標準時間)", intlZone: "Asia/Taipei"}

Issue description

moment.tz('2:05 PM · Nov 12, 2010 ', ' h:mm A · MMM D, YYYY', 'America/New_York') ,
0002-05-12 20:10:00 , should be 2010, not 0002, I think the code may have some bug to fix.

the moment.min.js are fine to format string
moment('2:05 PM · Nov 12, 2010 ', ' MMMM D, YYYY h:mm A', true);
2010-11-12 14:05:00

same result with js from momentjs.com

<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-timezone-with-data.js"></script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions