I need to get the current time to form a timer . But there is an issue with getting the exact time

I have a start_time and end time from a resource. I need to get the current time to check if this end time has passed. I was using moment for this..but the issue I'm facing is that the moment is picking time from my local computer which is few minutes slower than the actual time.

Is there a way to get the correct current time without taking the local server time.

Also I need to find the time difference between current and end time both in new york time zone. When using moment() it's giving utc time with moment().format() only I'm getting the correct value but it's a string this is in case of current time. For end time I did moment(end_time) which is giving the right result. If i use format it goes to a different time zone. How can I do a subtraction to find the time difference .

1 Like

hopefully I haven't misunderstood, but I made a little JS Fiddle thing for you to show finding the difference as well as using UTC and other ways to get and display the current date/time. let me know if it isn't helpful or if there's something you want me to add.

Sorry but where can I find it

wow my bad, I must have got distracted and somehow managed to forget to paste the link :grimacing:

1 Like

Thank you

1 Like

Awesome, @bobthebear

@Aj3107 Let us know if you're still working on any of the date/times you need for your app!

It's all good now. Thanks for the help