Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date is formatted correctly but element's textContent displays 'invalid date' #4853

Closed
geopic opened this issue Nov 8, 2018 · 1 comment
Closed

Comments

@geopic
Copy link

geopic commented Nov 8, 2018

Description of the Issue and Steps to Reproduce:

// No warning in console about deprecation with "value provided is not in a recognised
// RFC2822 or ISO format", but text displays "Invalid date" on the page
element.textContent = moment(entry['date'], View.getSiteValues()['longdate']());

// Deprecation warning in console but text displays the date correctly
element.textContent = moment(entry['date']).format(View.getSiteValues()['longdate']());

I am stuck between having a valid date but getting a deprecation warning in the console or formatting it 'properly' but making the date invalid.

Please include the values of all variables used.

  • entry['date'] - moment(moment(), moment.ISO_8601)

  • View.getSiteValues()['longdate']() - 'Do MMMM YYYY'

Environment: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0

Other information that may be helpful:

  • The time zone setting of the machine the code is running on
    Thu Nov 08 2018 15:54:38 GMT+0000 (Greenwich Mean Time)

  • The time and date at which the code was run
    08/11/2018, 15:54:38

  • Any other libraries / tools in use
    Node.js v8.11.1 with Express 4.16.0

@marwahaha
Copy link
Member

You can check is the object is valid:
https://momentjs.com/docs/#/parsing/is-valid/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants