In C# DateTimeOffset
has FromUnixTimeSeconds
:
// converts to UTC DateTimeOffset
var dtOffset = DateTimeOffset.FromUnixTimeSeconds(1530291339);
// if you need a DateTime you can
var dt = dtOffset.UtcDateTime;
// dtOffset.ToString() for example above:
// 6/29/2018 4:55:39 PM
DateTimeOffset also has FromUnixTimeMilliseconds
method. Please see DateTimeOffset for more info.
The methods FromUnixTimeSeconds
and FromUnixTimeMilliseconds
convert the UNIX timestamp (since 01/01/1070) date to a UTC DateTimeOffset.
The Offset property value of the returned DateTimeOffset instance is TimeSpan.Zero, which represents Coordinated Universal Time.
It can be converted to the time in a specific time zone by calling the TimeZoneInfo.ConvertTime() method.
That's just the time stamp. Simply parse the date by doing new Date(<timestamp>)
const date = new Date().getTime(); console.log(date); // <-- your number console.log(new Date(date)); // <-- convert the timestamp to a date
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
https://stripe.com/docs/api/skus/object?lang=dotnet#sku_object-created
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.