I need to use the timestamps that come from the sensors, and I get that information from lastdown_RAW, and lastup_RAW on the sensors content. The problem is I have no idea of how to format the timestamp that comes back. This is an example of the timestamp: 40190.5279598380. Excel seems to know how to format it, but I need to insert it straight into a database, and I need to work with the date/ time. If you could point me in the right direction, that would be great.
4 Replies
PRTG Network Monitor uses the following definition for date and time values: The value represents the number of days that have passed since 12/30/1899 (a date defined as a standard once, which is also what triggered the panic about Y2K).
This is a notation that also exists in many currently implemented programs, e.g. Excel. If you place the value in a cell, select this cell and then change the format type for the value to a date format of your choice, it will display the date in the selected format.
Some databases, however, require the values to be computed beforehand - and not everyone uses Excel. In those cases, it makes sense to know the computational process.
Computing the value
Following are some examples of TDateTime values and their corresponding dates and times:
0 12/30/1899 12:00 midnight 2.75 01/01/1900 06:00 pm -1.25 12/29/1899 06:00 am 35065 01/01/1996 12:00 midnight
The integral part of a value is the number of days that have passed since 12/30/1899. The fractional part of a value is the fraction of a 24 hour day that has elapsed.
To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value.
Created on Feb 25, 2010 2:03:00 PM by
Patrick Hutter [Paessler Support]
(6,534)
●3
●3
Last change on Apr 5, 2012 1:14:04 PM by
Patrick Hutter [Paessler Support]
(6,534)
●3
●3
Converting the timestamp value using vb.net
This little vb.net function converts the timestamp value to a normal date and time string:
Public Shared Function TimeRaw2String(ByVal timeRaw As String, Optional ByVal timeOnly As Boolean = False) As String
Dim d As DateTime = System.TimeZone.CurrentTimeZone.ToLocalTime(DateTime.FromOADate(CDbl(timeRaw.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator))))
If timeOnly Then Return d.ToLongTimeString
Return d.ToShortDateString & " " & d.ToLongTimeString
End Function
Created on Mar 12, 2010 10:59:50 AM by
PRTGToolsFamily
(5,444)
●3
●2
Last change on Mar 15, 2010 10:07:25 AM by
Daniel Zobel [Paessler Support]
(24,083)
●3
●3
Hello, is it possible to convert this kind of timestamp with PHP or Javascript?
Created on Mar 12, 2010 1:31:31 PM by
Erkan
(0)
Last change on Mar 12, 2010 2:08:19 PM by
Aurelio Lombardi [Paessler Support]
(8,199)
●3
●1
Converting prtg timestamp value using php
function prtg_timestamp_to_unix_timestamp ($prtg_timestamp) {
if (!is_numeric($prtg_timestamp)) return $prtg_timestamp;
$past = ($prtg_timestamp-25569)*86400;
$unix_timestamp = $now-$past;
return $unix_timestamp;
}
Created on Oct 13, 2010 1:48:44 AM by
hang jae cho
(0)
●2
Last change on Jan 31, 2012 10:29:41 AM by
Torsten Lindner [Paessler Support]
(17,330)
●3
●1
Please log in or register to enter your reply.
Add comment