0

I'm having problem with moment-range due to timezone! I get events from a database that return a string, e.g.

start:"2019-02-08T12:30:00Z"
end:"2019-02-08T13:30:00Z"

When I put it inside fullcalendar v3 it will add my locale (GMT+1), it is shown correctly inside the calendar (12:30), but when I'm adding a new date from my form, f.e.

start:08/02/2019 - 14:30
end:08/02/2019 - 17:30

When I create a moment.range it says it overlap (adjacent is true) due to moment adjusting the timezone! How can I manage event creation without worrying about time zones?

EDIT: Yeah sorry for the lack of information.

I'm using this plugin: moment.range from: https://github.com/rotaready/moment-range

New event date from bootstrap datetimepicker from: https://eonasdan.github.io/bootstrap-datetimepicker/

Now I solved my problem working with utc time of moment.js objects so now all overlaps work as expected!

TheEnigmist
  • 906
  • 1
  • 10
  • 23
  • 1
    Moment doesn't offer ranges on its own, are you using a plugin/add-on? Which one? Also, please show us [an MCVE](https://stackoverflow.com/help/mcve) that illustrates your problem. As written, we can't really tell if you are asking about FullCalendar, Moment, or some plugin for Moment. – Matt Johnson-Pint Jan 31 '19 at 20:14
  • 1
    If your timezone is GMT +1, then the local time for 2019-02-08T12:30:00Z is 13:30, not 12:30. A date in a format like "08/02/2019 - 14:30" should be treated as local as there is no timezone information associated with it, so (assuming d/m/y format) it will be treated as the same moment in time as "2019-02-08T13:30:00Z" (given your timezone of +1). – RobG Jan 31 '19 at 22:48
  • edited and solved forcing all moment to work with utc time – TheEnigmist Feb 01 '19 at 16:06

1 Answers1

1

I solved my problem simply using moment.utc() instead of moment()

TheEnigmist
  • 906
  • 1
  • 10
  • 23