Discussion:
[SR-Users] Unix timestamp with millisecond precision
(too old to reply)
Grant Bagdasarian
2014-10-22 08:40:51 UTC
Permalink
Hello,

I'm currently using the $TS psuedovariable to get the current unix timestamp, but this only returns the timestamp up to a second precision.
Is it possible in kamailio to get the current unix timestamp with milliseconds precision?

Regards,

Grant
Andrew Pogrebennyk
2014-10-22 12:01:48 UTC
Permalink
See http://www.kamailio.org/wiki/cookbooks/4.2.x/pseudovariables#tv_name
Post by Grant Bagdasarian
Hello,
I’m currently using the $TS psuedovariable to get the current unix
timestamp, but this only returns the timestamp up to a second precision.
Is it possible in kamailio to get the current unix timestamp with milliseconds precision?
Regards,
Grant
Grant Bagdasarian
2014-10-22 13:31:12 UTC
Permalink
Awesome! Thanks!

-----Original Message-----
From: sr-users-bounces-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org [mailto:sr-users-bounces-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org] On Behalf Of Andrew Pogrebennyk
Sent: Wednesday, October 22, 2014 2:02 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Unix timestamp with millisecond precision

See http://www.kamailio.org/wiki/cookbooks/4.2.x/pseudovariables#tv_name
Post by Grant Bagdasarian
Hello,
I'm currently using the $TS psuedovariable to get the current unix
timestamp, but this only returns the timestamp up to a second precision.
Is it possible in kamailio to get the current unix timestamp with milliseconds precision?
Regards,
Grant
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Grant Bagdasarian
2014-10-23 07:00:06 UTC
Permalink
The $TV(Sn) returns a string containing the seconds and milliseconds.
To get the current DateTime I have to add the seconds since standard epoch.
What about the milliseconds? Are those the current milliseconds?

I'm using the following C# code to create a DateTime object using the value from $TV(Sn):

Is this correct?

string[] timestampParts = timestamp.Split('.');
int seconds = Convert.ToInt32(timestampParts[0]);
int milliseconds = Convert.ToInt32(timestampParts[1].Substring(0, 3));
DateTime returnDate = new DateTime(1970, 1, 1, 0, 0, 0, milliseconds).AddSeconds(seconds).ToLocalTime();



-----Original Message-----
From: sr-users-bounces-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org [mailto:sr-users-bounces-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org] On Behalf Of Andrew Pogrebennyk
Sent: Wednesday, October 22, 2014 2:02 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] Unix timestamp with millisecond precision

See http://www.kamailio.org/wiki/cookbooks/4.2.x/pseudovariables#tv_name
Post by Grant Bagdasarian
Hello,
I'm currently using the $TS psuedovariable to get the current unix
timestamp, but this only returns the timestamp up to a second precision.
Is it possible in kamailio to get the current unix timestamp with milliseconds precision?
Regards,
Grant
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+***@public.gmane.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Loading...