Comments (7)
Yes, it seems like it interprets the first parameter as local time. For me (sitting in Germany), it is:
moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T05:55:00-05:00"
But if I provide the ISO-formatted UTC time:
moment.tz("2013-11-18T11:55Z", "America/Toronto").format();
"2013-11-18T06:55:00-05:00"
I would also appreciate a more detailed documentation.
from moment-timezone.
This appears to be mostly correct in the latest release (0.0.3). Most timezones seem to behave consistently with documentation now, but I've run into a strange one:
// Reported examples now work as documented (from San Francisco, anyway)
> moment.tz("2013-11-18 11:55", "America/Toronto").format();
'2013-11-18T11:55:00-05:00'
> moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
'2013-12-18T00:00:00-05:00'
// a few other examples
> moment.tz('2014-01-01', 'America/New_York').format()
'2014-01-01T00:00:00-05:00'
> moment.tz('2014-01-01', 'Europe/London').format()
'2014-01-01T00:00:00+00:00'
> moment.tz('2014-01-01 00:00:00', 'Europe/London').format()
'2014-01-01T00:00:00+00:00'
// However, London seems to be off by an hour, once, in 2012:
> moment.tz('2012-10-27', 'Europe/London').format()
'2012-10-27T00:00:00+01:00'
> moment.tz('2012-10-28', 'Europe/London').format()
'2012-10-28T01:00:00+01:00'
> moment.tz('2012-10-29', 'Europe/London').format()
'2012-10-29T00:00:00+00:00'
from moment-timezone.
The last one is just due to daylight saving time. Or what do you find strange here, @kroo?
EDIT: Sorry, misread your post. Yes the 2012-10-28 example is strange.
from moment-timezone.
Just as a side note, the moment-timezone website still seems to be using an older version, which really confused me trying to test in the console.
from moment-timezone.
This is fixed in #93.
from moment-timezone.
Nice! Thanks
from moment-timezone.
This is released in 0.1.0
.
from moment-timezone.
Related Issues (20)
- The DST calculation does not take effect. HOT 3
- import moment from 'moment-timezone'; import 'moment/min/locales'; not working HOT 5
- Can not set default timezone HOT 2
- Wrong timezone conversion
- error TS2350: Only a void function can be called with the 'new' keyword. new moment(); HOT 3
- 2023d is out HOT 2
- Some tz.guess() tests are failing in 2024 HOT 1
- Canada/Yukon offset before 1967 May 27 is wrong HOT 1
- How does moment.tz(unixTimestamp,timezone) and moment.tz.guess() work? HOT 1
- How can I use moment-timezone with 10 year data range with Typescript types HOT 1
- Moment Timezone has no data for Europe/Ljubljana
- Kazakhstan will switch to a single time zone, UTC+05:00, on March 1, 2024. HOT 1
- 2024a released HOT 1
- Test failure due to rounding error HOT 2
- Timezone Error in v0.5.45 HOT 1
- Wrong Kazakhstan Timezone in 0.5.45 HOT 1
- Incorrect Timezone Offset for 'Asia/Almaty' HOT 1
- The moment-timezone get the time zone of Kazakhstan Asia/Almaty in January 2024 to the DST. HOT 3
- Is there an alternative to moment-timezone with bundled IANA TZ DB? HOT 1
- Getting spilt issue while using moment and moment-timezones HOT 1
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-timezone.