Moment js: Keep UTC date/time in UTC only [duplicate] Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experiencemoment js is returning wrong formatted values for an iso timestampMomentJS getting JavaScript Date in UTCHow to convert local time string to UTC?Convert UTC/GMT time to local timeHow do you convert a JavaScript date to UTC?How do I get the current date in JavaScript?Daylight saving time and time zone best practicesConvert UTC Epoch to local dateConvert UTC date time to local date timeConverting datetime.date to UTC timestamp in PythonRound to at most 2 decimal places (only if necessary)Moment JS - parse UTC and convert to Local and vice versa
Fishing simulator
How do I automatically answer y in bash script?
How can players take actions together that are impossible otherwise?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Unexpected result with right shift after bitwise negation
How should I respond to a player wanting to catch a sword between their hands?
How do you clear the ApexPages.getMessages() collection in a test?
Why is there no army of Iron-Mans in the MCU?
What computer would be fastest for Mathematica Home Edition?
Does a C shift expression have unsigned type? Why would Splint warn about a right-shift?
How to market an anarchic city as a tourism spot to people living in civilized areas?
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
Can I throw a sword that doesn't have the Thrown property at someone?
Two different pronunciation of "понял"
How are presidential pardons supposed to be used?
Need a suitable toxic chemical for a murder plot in my novel
Why does tar appear to skip file contents when output file is /dev/null?
Strange behaviour of Check
Stars Make Stars
How is simplicity better than precision and clarity in prose?
Single author papers against my advisor's will?
Estimate capacitor parameters
What kind of display is this?
Geometric mean and geometric standard deviation
Moment js: Keep UTC date/time in UTC only [duplicate]
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experiencemoment js is returning wrong formatted values for an iso timestampMomentJS getting JavaScript Date in UTCHow to convert local time string to UTC?Convert UTC/GMT time to local timeHow do you convert a JavaScript date to UTC?How do I get the current date in JavaScript?Daylight saving time and time zone best practicesConvert UTC Epoch to local dateConvert UTC date time to local date timeConverting datetime.date to UTC timestamp in PythonRound to at most 2 decimal places (only if necessary)Moment JS - parse UTC and convert to Local and vice versa
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
This question already has an answer here:
moment js is returning wrong formatted values for an iso timestamp
2 answers
date = moment(startDate).startOf('day');
date.format('2019-01-01't)
Above code is converting UTC date to local date. How do i keep UTC date UTC?
startDate is a datetime string in iso format
javascript momentjs utc
marked as duplicate by VincenzoC, Community♦ Mar 11 at 7:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
moment js is returning wrong formatted values for an iso timestamp
2 answers
date = moment(startDate).startOf('day');
date.format('2019-01-01't)
Above code is converting UTC date to local date. How do i keep UTC date UTC?
startDate is a datetime string in iso format
javascript momentjs utc
marked as duplicate by VincenzoC, Community♦ Mar 11 at 7:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
1
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09
add a comment |
This question already has an answer here:
moment js is returning wrong formatted values for an iso timestamp
2 answers
date = moment(startDate).startOf('day');
date.format('2019-01-01't)
Above code is converting UTC date to local date. How do i keep UTC date UTC?
startDate is a datetime string in iso format
javascript momentjs utc
This question already has an answer here:
moment js is returning wrong formatted values for an iso timestamp
2 answers
date = moment(startDate).startOf('day');
date.format('2019-01-01't)
Above code is converting UTC date to local date. How do i keep UTC date UTC?
startDate is a datetime string in iso format
This question already has an answer here:
moment js is returning wrong formatted values for an iso timestamp
2 answers
javascript momentjs utc
javascript momentjs utc
edited Mar 8 at 15:05
aWebDeveloper
asked Mar 8 at 14:59
aWebDeveloperaWebDeveloper
19.8k29123201
19.8k29123201
marked as duplicate by VincenzoC, Community♦ Mar 11 at 7:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by VincenzoC, Community♦ Mar 11 at 7:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
1
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09
add a comment |
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
1
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
1
1
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09
add a comment |
1 Answer
1
active
oldest
votes
From the moment docs:
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
So even though your datestring is UTC and moment is correctly parsing the date, it still displays the output in local time unless you use moment.utc(). To display in utc:
const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From the moment docs:
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
So even though your datestring is UTC and moment is correctly parsing the date, it still displays the output in local time unless you use moment.utc(). To display in utc:
const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>add a comment |
From the moment docs:
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
So even though your datestring is UTC and moment is correctly parsing the date, it still displays the output in local time unless you use moment.utc(). To display in utc:
const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>add a comment |
From the moment docs:
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
So even though your datestring is UTC and moment is correctly parsing the date, it still displays the output in local time unless you use moment.utc(). To display in utc:
const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>From the moment docs:
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
So even though your datestring is UTC and moment is correctly parsing the date, it still displays the output in local time unless you use moment.utc(). To display in utc:
const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>const s = '2019-03-08T14:59:40Z';
const date = moment.utc(s).startOf('day').format();
console.log(date);
// 2019-03-08T00:00:00Z<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>edited Mar 8 at 15:30
answered Mar 8 at 15:23
benvcbenvc
6,9531928
6,9531928
add a comment |
add a comment |
my date is already in utc format. Dont want to convert to utc.
– aWebDeveloper
Mar 8 at 15:06
moment(date, 'MM-DD-YYYY').utc().format("YYYY-MM-DD HH:mm"), is this what you want?
– Wimanicesir
Mar 8 at 15:08
1
@Alexis i guess he gets a utc value but after the format he converts it to non utc
– Wimanicesir
Mar 8 at 15:09