spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.97k stars 183 forks source link

Difference of two timezone #309

Closed dipeshhkc closed 2 years ago

dipeshhkc commented 2 years ago

// browser time let now = spacetime.now(); // now.time() -> 2:11pm

//client time let client = now.goto("America/Los_Angeles"); // client.time() -> 12:26am

let dif = now.diff(client, 'minute'); // diff -> 0

Why do I get 0 here? Am I missing something?

spencermountain commented 2 years ago

yeah, awkward situation. They're the same time! i swear we had a method for this, but I can't find it. you can always do something like this https://runkit.com/spencermountain/6193c3b2a6e04600084feaf0

which is a little awkward, but should work fine.

if there are any proposals for a better way to handle this, I'm happy to clean it up cheers

dipeshhkc commented 2 years ago

@spencermountain Thank you for your help :bow: It worked. Let me know if you find this

i swear we had a method for this, but I can't find it.