I have had look around stackoverflow, and even looked at some of the suggested questions and none seem to answer, how do you get a unix timestamp in C#?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
This is what I use:
Keep in mind that this method will return the time as Coordinated Univeral Time (UTC).
You get a unix timestamp in C# by using DateTime.UtcNow and subtracting the epoc time of 1970-01-01.
e.g.
DateTime.Now
can be replaced with anyDateTime
object that you would like to get the unix timestamp for.This solution helped in my situation:
using helper in code: