Comments (1)
It seems that is because the .format('MM-DD-YYYY')
does not comply RFC2822 nor ISO 8601 formats (https://momentjs.com/docs/#/parsing/string/).
For example, with ISO 8601 format:
const today = moment().format('YYYY-MM-DD');
const yesterday = moment().format('YYYY-MM-DD');
const result = moment(today).isSame(yesterday);
console.log(result); // Chrome: true, Safari: true, Firefox: true
With any other format, the format should be set when creating the moment objects (https://momentjs.com/docs/#/parsing/string-format/):
const today = moment().format('MM-DD-YYYY');
const yesterday = moment().format('MM-DD-YYYY');
const result = console.log(moment(today, 'MM-DD-YYYY').isSame(moment(yesterday, 'MM-DD-YYYY')));
console.log(result); // Chrome: true, Safari: true, Firefox: true
from moment.
Related Issues (20)
- moment.isValid is returning true for day as 0 HOT 3
- Module not found: Error: Can't resolve 'moment' in .... - React SSR
- toJSON() on invalid dates produces null, although the type definition says that it always returns string
- Update follow-redirects dependency to fix security vulnerability in Moment HOT 1
- Wrong result in date diff in days HOT 1
- Deprecation warning HOT 1
- Incorrect diff for dates before and after March 10th HOT 1
- Endof 2024 april is 2024/04/30(mis-calculated) not a issue
- Changed timezone 'Asia/Almaty' wat +6 => now +5 HOT 1
- Time Format without AM and PM HOT 3
- `ddd DD` is an invalid format whereas `DD`, `ddd`, and `ddd YYYY` are valid
- Unhandled edge case for isValid() function. HOT 1
- The output result of startOf ('day ') is incorrect
- Can someone tell me how EXCATLY I need to install this package?
- Request to get device date formart
- Dark links detected in version 2.29.4
- Moment.js Locale Override Mystery - AM/PM Parsing Gone Wrong!"
- 5 tests failed. diff:diff across DST (3379.17) diff:diff across DST (3379.19) duration from moments:pure year diff (3388.1) duration from moments:pure year diff (3388.2) start and end of units:start of quarter (3720.7)
- Methods like toDateTimeString and toDateString required.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moment.