Questions tagged [gettime]

Use for questions related to the 'gettime' method, for getting the time in JavaScript.

The getTime() method returns the numeric value corresponding to the time for the specified date according to universal time.

You can use this method to help assign a date and time to another Date object. This method is functionally equivalent to the valueOf() method.

Read more in the ref.

142 questions
0
votes
1 answer

Using Conditions cause React render limit error

I've made a dark mode function. There are using checkbox and getting current hour to change this mode. When I write a traditional If statement it cause an error of render limits (like stack overflow). Here's my code: const curTime = new Date(); let…
MadOwlSR
  • 5
  • 3
0
votes
2 answers

now.getTime() inside useEffect doesn't work

I wanted to record how many time passed until user click the button. My plan was like: (the time when user enter the page) - (the time when user click the button) = how many milliseoconds passed! but my code had an bug and error. my useEffect didn't…
Mocha
  • 129
  • 1
  • 7
0
votes
0 answers

Groovy: Export Data - How to set unix start time from now to a certain point in the past?

I am currently exporting data from Grafana. I do that using a script which looks like this one: JsonSlurper slurper = new JsonSlurper() println "Collect list of servers:" def result = slurper.parse(new URL('http://xyz')) def servers =…
Tobitor
  • 1,388
  • 1
  • 23
  • 58
0
votes
1 answer

getting the correct time for specific area \ time zone

I'm currently getting the time in my client using Angular 11 (TypeScript). I have noticed that actually, each user(using my website) can have a different hour , according to his\her location. I'm using the follwoing code to get the current time: let…
JumpIntoTheWater
  • 1,306
  • 2
  • 19
  • 46
0
votes
1 answer

Javascript getTime() returns different time than time object itself

Javascript getTime() returns different time than time object itself. function doTime(){ var data = []; var newDate = new Date('2020-01-01'); for (var i = 0; i < 10; i++) { newDate.setTime(newDate.getTime() + (1000 * 60 * 60)); …
Harijs Krūtainis
  • 1,261
  • 14
  • 13
0
votes
6 answers

Javascript - How do I make getTime() uniform across all computers?

Right now I'm getting a different number on my Desktop than I am on my laptop.
Clinton Jooooones
  • 887
  • 3
  • 12
  • 19
0
votes
1 answer

Why does JavaScript runtime error: Object doesn't support property or method 'getTime' happen?(getTime is not a function)

The following code is MVC C# cshtml document. @{ Layout = null; ViewBag.Title = "Test"; }