Reputation: 2465
I am reading an API documentation that says I have to pass current time to it in following format:
{
"date": "\/Date(1508262132936)\/"
}
And the one-line explanation of this format says: "Date in UTC format". I tried passing DateTime.Now; DateTime.Now.UtcNow; DateTime.Now.ToUniversalTime();
but all of those output BadRequest reply. What is the correct format here?
Upvotes: 0
Views: 457
Reputation: 14456
Looks like a Unix epoch time, use the ToUnixTimeSeconds
method on DateTimeOffset:
var date = DateTime.UtcNow;
new DateTimeOffset(date).ToUnixTimeSeconds()
Upvotes: 2