I'm working with pbx for voip calls. One aspect of pbx is that you can choose to receive CDR packages. Those packages have 2 timestamps : "utc" and "local", but both seem to always be the same.
Here's an example of a timestamp : "1268927156".
At first sight, there seems to be no logic in it. So I tried converting it several ways, but with no good result. That value should provide a time around 11am (+1GMT) today.
Things I tried:
and some others I can't remember right now.
Am I missing something stupid here?
Thanks in advance
The ToString() method of the DateTime class is used to convert a DateTime date object to string format. The method takes a date format string that specifies the required string representation.
On the Data tab of the ribbon, click Text to Columns. Click Next >, then Next > again. Under 'Column data format', select Date, then select YMD from the drop-down next to the Date option button. Click Finish.
Converting timestamp to datetime We may use the datetime module's fromtimestamp() method to convert the timestamp back to a datetime object. It returns the POSIX timestamp corresponding to the local date and time, as returned by time. time().
This looks like Unix time.
1268927156 = Thu, 18 Mar 2010 15:45:56 GMT
And a code sample:
DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime time = startDate.AddSeconds(1268927156 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With