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
1
vote
0 answers

clock_gettime Speed Difference Across Machines

I'm trying to use clock_gettime(CLOCK_MONOTONIC, &tp) for timestamping, and I'm finding that it has very different performance across various machines. For example, on a machine with a Xeon X5670 processor running kernel 2.6.27, it takes 682ns per…
1
vote
2 answers

Algorithm of Java Date getTime

How does java.util.Date.getTime method convert a given date & time into long number? Java API documents say that - "Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object." Appreciate any help.
Ujjwal
  • 603
  • 12
  • 23
0
votes
3 answers

Making countdown function in jQuery

I am newbie and need ur help. I have a problem on finding out days, hours, minutes and seconds. I dont know what to update minutes after seconds will reach 60 and same with hours and days. I am trying to countdown to a given date in a format of…
FoxKllD
  • 971
  • 3
  • 13
  • 22
0
votes
0 answers

Date comparison for validation

good afternoon! I would like to know how I can be creating a code that expires within a time, using getDate and time. For example, having an input field, where I check if a token exists, and compare the dates to check if it is active within the…
Santon99
  • 1
  • 2
0
votes
0 answers

Get angles for clock hands

I know that I can use getHours() and getMinutes() and getSecond() in JavaScript and show the exact time of my computer, but how should I sync that with the shape of the clock? const activeb = document.querySelector(".run") const mysec =…
0
votes
0 answers

Need help having a countdown JS script countdown from EST and not the local computer time

I am writing a HTML embed that displays a countdown for wednesday at 20:30 EST. Everytime it hits that date and time it will set the date to the following wednesday and start counting down the date. The issue is that I am using the .getTime()…
Nik Thomas
  • 13
  • 6
0
votes
2 answers

Get array of distinct date(not time) from array of objects in javascript

Hey I am working on a attendance project in reactjs , I am facing a problem that I received an array of attendances e.g (in range of last two weeks ) . All I need is filter an array of distinct date, not the time but only date . (Time can be…
0
votes
2 answers

How I can convert any Date to Los Angeles Time (PST) and then convert this one to Unix timestamp?

I'm trying to convert my local date or any local date to PST and then into timestamp. For example, this code works to convert the local time to PST: var offset = -7; var result = new Date(new Date().getTime() + offset * 3600 * 1000) …
0
votes
1 answer

setting timezone for timestamp in angular

Hello guys i looked the internet and here but i couldnt find the solutuon , anyway here is my problem. I have a date and I need to convert this date to timestamp, but I need to do this according to canadian time. I am using the getTime() method, but…
0
votes
1 answer

Always display 2 digits for date/time with `getDate`

I'm using javascript to display the current (live) date/time on a website. I want all the numbers (date, hour, minute, second) to always display with 2 digits. So if a number is (0-9) it is prefixed with a '0' I've managed to do this for the time…
user1406440
  • 1,329
  • 2
  • 24
  • 59
0
votes
1 answer

My JS console says that .getTime is not a function when i use the getTime() method in JS

I am not able to use the .getTime() method, can someone help me? Error message in link! The original date is just from basic html date input. JS: document.getElementById("lastMenDate").addEventListener("change", function () { var inputMen =…
0
votes
1 answer

Why a std::get_time() simple example fails parsing on WSL Ubuntu 20.04?

I am trying to run a very simple example of the std::get_time() function but the parse is failing. #include #include #include #include int main() { std::tm t = {}; std::istringstream …
0
votes
1 answer

Django python + javascript countdown – different times in Python and Javascript?

EDIT #2 Again, I spend some time with the code and some more research: In my views.py I do the following timestamp = datetime.combine(inst.date, inst.time).strftime('%s') timestamp get passed through the template to javascript. But the…
treeert
  • 1
  • 4
0
votes
1 answer

What if I give parameter for Date.prototype.getTime()?

I create date in two ways: new Date('some date').getTime(); new Date().getTime('some date'); I did it before I had read on MDN, that Date.prototype.getTime() doesn't have parameter. It means second way is wrong. Nevertheless, it gives the same…
0
votes
1 answer

What is wrong with clock_gettime with CLOCK_REALTIME?

Consider the following code: struct timespec ts; uint64_t start_time; uint64_t stop_time; if (clock_gettime(CLOCK_REALTIME, &ts) != 0) { abort(); } start_time = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec; /* some computation... */ if…
DaBler
  • 2,695
  • 2
  • 26
  • 46