0

Currently i'm collecting data using joulemeter developed from Microsoft. It records data and time in timestamp format, but in different format. I try to convert using normal but couldn't get accurate time and data. And i'm going to use the data in php. Below is the data I get, first column is the record of timestamp.

TimeStamp (ms)   Total Power (W)     CPU (W)     Monitor (W)     Disk (W)    Base (W)    Application (W)
63573171824975  27      0.2 4.4 0   22.4    --
63573171825988  27      0.2 4.4 0   22.4    --
63573171827002  26.9    0.1 4.4 0   22.4    --
63573171828016  27      0.1 4.4 0   22.4    --
63573171829030  27      0.1 4.4 0   22.4    --
63573171830044  27      0.1 4.4 0   22.4    --
63573171831058  26.9    0   4.4 0   22.4    --
63573171832074  26.9    0   4.4 0   22.4    --
63573171833086  26.9    0.1 4.4 0   22.4    --
63573171834100  26.9    0.1 4.4 0   22.4    --
63573171835115  26.9    0   4.4 0   22.4    --

I have do searched online but found no solution. That is a thread found here Microsoft, but no one answer the question. Appreciate if can help.

Edited: Additional information: I notice that joulemeter shows the power model from 7/3/2015 4:41:08 PM Will it start counting from this date instead of windows timestamp 1601/1970? Which means the offset of the timestamp is different.

user1403675
  • 49
  • 4
  • 9
  • Do you know what that timestamp represents? – Parris Varney Jul 29 '15 at 11:42
  • try this : http://stackoverflow.com/questions/10411954/convert-windows-timestamp-to-date-using-php-on-a-linux-box#answer-10412203 – mmm Jul 29 '15 at 11:49
  • @mmm thx, i tried. tUnix = tWindow/(10*1000*1000)-11644473600; I try to use this. At the end this is the result 15-03-1601 20:50:43 the time might be correct but instead of the date. – user1403675 Jul 29 '15 at 12:35

2 Answers2

0

You need to learn about timestamps. In short, they are the number of seconds passed since the Unix Epoch. (the dawn of time as far as computers are concerned).

$timeStamp = 63573171824975;
echo date('jS M Y, g:i:a',$timeStamp);

Outputs: 26th May 1940, 7:26:pm

The 'mask', in this case 'jS M Y, g:i:a', can be modified to suit the format that you wish to display the timestamp in. Different 'masks' can be found here: http://php.net/manual/en/function.date.php

Once you understand this, switch to using PHP's DateTime Object instead. http://php.net/manual/en/book.datetime.php

MaggsWeb
  • 3,018
  • 1
  • 13
  • 23
0

after whole day of research, finally i'm able figure the solution. The timestamp format mentioned is not an UNIX timestamp which start from 00:00:00 1/1/1970 and currently using as start date on PHP date() function. It's actually start from 0001-01-01 00:00:00.

number of second between 0001-01-01 00:00:00 and 00:00:00 1/1/1970 = 62136892800

Solution:

//timestamp in millisecond
$timestamp = 63573171824975/1000 - 62136892800;
echo date('r',$timeStamp);

//result = Tue, 7 Jul 2015 03:49:35 +0800
user1403675
  • 49
  • 4
  • 9