Trying to Present in UTC, and Save in UTC. Cannot get data without timezone conversion
See original GitHub issueEnvironment
Tech | Version |
---|---|
material-ui-pickers | 1.0.0-rc.4 |
material-ui | 1.0.0-beta.33 |
React | 16.2.0 |
Browser | Chrome |
Platform |
Steps to reproduce
- Date & Time Picker Basic Example
Expected behavior
Component to send me back either:
A) Format like so: 2018-04-04T13:48:00.000Z
B) Accept my UTC=true flag, and NOT apply a timezone conversion as it is here: Fri Apr 20 2018 10:28:00 GMT-0700 (PDT)
Actual behavior
i) I can only receive the 2018-04-04T13:48:00.000Z
format when I wrongly send a default value date string yyyy-mm-dd. This comes through as {}._i when the component submits. As soon as I send the proper selectedValue through, the {}._I property becomes Fri Apr 20 2018 10:28:00 GMT-0700 (PDT)
.
ii) Am am applying UTC=true to the component. I can see _isUTC
as true in the submission object. But the datetime format is still having the PDT conversion applied.
import React from 'react';
import moment from 'moment-timezone';
import MomentUtils from 'material-ui-pickers/utils/moment-utils';
import MuiPickersUtilsProvider from 'material-ui-pickers/utils/MuiPickersUtilsProvider';
import { DateTimePicker } from 'material-ui-pickers';
moment.tz.setDefault('UTC');
function DateAndTimePicker(props) {
const { handleChange, label, selectedDate } = props;
return (
<MuiPickersUtilsProvider
moment={ moment }
utils={ MomentUtils } >
<DateTimePicker
disablePast
label={ label }
onChange={ handleChange }
value={ selectedDate }
/>
</MuiPickersUtilsProvider>
);
}
export default DateAndTimePicker;
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Trying to Present in UTC, and Save in UTC. Cannot get data ...
I can see _isUTC as true in the submission object. But the datetime format is still having the PDT conversion applied. import React...
Read more >Parse date without timezone javascript - Stack Overflow
I want to parse time: without time zone. without calling a constructor Date.UTC or new Date(year, month, day) .
Read more >Storing UTC is not a silver bullet | Jon Skeet's coding blog
The general advice of “just convert all local date/time data to UTC and store that” is overly broad in my view. For future...
Read more >Converting old dates of UTC format to timezone and daylight
Converting old dates of UTC format to timezone and daylight saving time HiOur timezone is +02:00 from UTC (Greenwhich) time.
Read more >Working with UTC time and converting it
Solved: Hi, I'm building an application for work travel, that is writing to a database that has the UTC timezone set, and then...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think he’s wanting the date to display in UTC instead of the local timezone, as the two expected behaviours listed are both in UTC. Is this possible?
this is my working solution
usage:
Using this could cause more harm then good