Languages
[Edit]
EN

C# / .NET - string date time to epoch timestamp in seconds

0 points
Created by:
Roseanne-Read
1365

In this article, we would like to show you how to string date time to epoch timestamp in seconds in C#.

Quick solution:

 

Practical example

Edit

In this example, we convert dateString to date using Parse() method, then we use Subtract() method with TotalSeconds property to get number of seconds that passed since the Epoch to specified date.

Output:

References

Edit
  1. Convert strings to DateTime | Microsoft Docs
  2. TimeSpan.TotalSeconds Property (System) | Microsoft Docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join