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.

128 questions
4
votes
3 answers

Convert UNIX timestamp to milliseconds

How can I use PHP to get a UNIX timestamp like what I get from the JS method .getTime()? I seem to be having trouble since .getTime() returns milliseconds. I know I have to convert the timestamps first for JS to read it, but how can I do…
MacMac
  • 30,042
  • 53
  • 142
  • 217
4
votes
3 answers

Calendar.getInstance().getTime() returning date in "GMT" instead of Default TimeZone

Calendar c = Calendar.getInstance(); System.out.println(c.getTime()); c.set(2007, 0, 1); System.out.println(c.getTime()); Output: Tue Sep 12 12:36:24 IST 2017 Mon Jan 01 12:36:24 IST 2007 But, When I use the same code in a different…
Dinesh Babu
  • 63
  • 1
  • 7
4
votes
2 answers

How Can I Tell if My struct tm Has Been Left in an Invalid State?

This is a question about invalid input, not invalid formatting. For example given the following code: tm bar; foo >> get_time(&bar, "%Y-%m-%d"); cout >> bar.tm_year >> bar.tm_mon >> bar.tm_mday >> endl; This is fine if I define: stringstream…
Jonathan Mee
  • 35,107
  • 16
  • 95
  • 241
4
votes
2 answers

ARM performance counters vs linux clock_gettime

I am using a Zynq chip on a development board ( ZC702 ) , which has a dual cortex-A9 MPCore at 667MHz and comes with a Linux kernel 3.3 I wanted to compare the execution time of a program so first a used clock_gettime and then used the counters…
akarapatis
  • 832
  • 8
  • 17
2
votes
1 answer

How do I get the time in seconds from epoch in javascript?

I assume I should be able to do it like so: var date = Math.round((new Date).getTime() / 1000); console.log(date); However, that is logging: 301332453318 Which if I run through this convertor ( http://www.epochconverter.com/ ) it outputs the date…
tsdexter
  • 2,775
  • 3
  • 30
  • 57
2
votes
1 answer

convert EST date to Unix Time Stamp in Javascript

I want to convert a date given in EST timezone to unix time stamp. I am not sure if the following lines of code gives me the unix time stamp of the EST date 2018-12-30. Can anyone please help. var estDate = '2018-12-30"; var d = new Date(estDate);…
Amrita
  • 21
  • 3
2
votes
1 answer

Two methods implement same algorithm one is taking running time more than other in java

I am trying to calculate running time of two methods using new Date().getTime(). the two methods follow same algorithm,and one of them increase some steps,however the method with less steps take more time . I am confusing of that. here is the two…
2
votes
3 answers

Difference between javascript getTime() and Java getTime()

It seems that Java and JavaScript give different results for negative millisecond values. JAVA: System.out.println(new Date(-12220000000000L)); Wed Sep 26 12:33:20 MST 1582 JavaScript: console.log(new Date(-12220000000000)); Date {Wed Oct 06 1582…
jrook
  • 3,226
  • 1
  • 14
  • 29
2
votes
9 answers

Detect last week of each month with javascript

what would be a way in javascript to detect the last week of each (current) month. Or last monday of the month?
devjs11
  • 1,728
  • 6
  • 35
  • 69
2
votes
2 answers

node.js What does Date#getTime() do?

I'm working on learnyounode module 13 right now. In the hints section it claims "Date#getTime() will also come in handy." I looked up the Date object and found the getTime method, but what does it mean when there's a hash instead of a period?
ajHurliman
  • 141
  • 2
  • 13
2
votes
2 answers

Javascript gettime()

I am trying to use gettime to sort my date string. But it is returning some vague values like. 1428303000000 16/06/2014 16:50 1389074040000 01/07/2014 16:54 The first date is smaller than second so its no. of milliseconds should also be…
Arun
  • 23
  • 3
2
votes
1 answer

Need clear idea about timespec structure

In my project I'm using struct timespec as follows struct timespec start, end; clock_gettime(CLOCK_REALTIME,&start); /* Do something */ clock_gettime(CLOCK_REALTIME,&end); It returns a value as ((((unsigned64)start.tv_sec) *…
Siva
  • 141
  • 1
  • 12
2
votes
1 answer

Date.getTime() is taking to much time to process when in spanish

I am trying to convert "yyyy-MM-dd'T'HHmmssZZ" to unix time in my app. This is my code: public String getCreatedAt() { String formattedCreatedAt = twitterCreatedAt.replace(":", ""); SimpleDateFormat dateFormat = new SimpleDateFormat( …
roiberg
  • 12,799
  • 11
  • 54
  • 87
2
votes
4 answers

why javascript's .getTime() + 24*60*60*1000 get's stack after 27 Oct 2013?

I was just creating a simple calendar when users clicks next it gets the following day, very simple code: var dateSelected = new Date('02/06/2013'); //any date var day = new Date(dateSelected.getTime() + 24*60*60*1000); alert(day.getDate()); that…
matt
  • 2,124
  • 4
  • 26
  • 54
1
vote
1 answer

Javascript's getTime() function shows incorrect values?

I'm missing something, but I cannot find any hint online. When I use Javascript's getTime() function it seems it does not count from 1970, 01, 01, 0, 0, 0, 0 i.e. midnight 1970, but from 1969, 12, 01, 1, 0, 0, 0 I set up following: var d = new…
vucibatina
  • 107
  • 1
  • 6
1
2
3
8 9