You’re probably trying to convert to a UNIX-like timestamp, which are in UTC:
yourDateTime.ToUniversalTime().Subtract(
new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
).TotalMilliseconds
This also avoids summertime issues, since UTC doesn’t have those.
More Related Contents:
- Conversion of a datetime2 data type to a datetime data type results out-of-range value
- Using DateTime in a SqlParameter for Stored Procedure, format error
- Is there any difference between DateTime in c# and DateTime in SQL server?
- How to get nullable DateTime out of the database
- In C#, is there any more elegant way to take a DateTime and calculate how many months until the "next" Quarter? [closed]
- C# how do i create a DateTime Variable that has the current date, but a different time? [closed]
- C#: SQL Server Connection String
- Given a DateTime object, how do I get an ISO 8601 date in string format?
- Is DateTime.Now the best way to measure a function’s performance? [closed]
- How to create a .NET DateTime from ISO 8601 format
- Specifying a custom DateTime format when serializing with Json.Net
- How to know if a DateTime is between a DateRange in C#
- Change system date programmatically
- Showing Difference between two datetime values in hours
- SQL Query slow in .NET application but instantaneous in SQL Server Management Studio
- How to format DateTime to 24 hours time?
- How do I get the AM/PM value from a DateTime?
- How do you get the current time of day?
- What’s the fastest way to bulk insert a lot of data in SQL Server (C# client)
- C# Datetimes: Conversion for different time zones
- Delete a single record from Entity Framework?
- Convert UTC DateTime to another Time Zone
- How to convert DateTime in Specific timezone?
- GO statements blowing up sql execution in .NET
- How to Identify the primary key duplication from a SQL Server 2008 error code?
- Is it possible to use SqlGeography with Linq to Sql?
- “The operation is not valid for the state of the transaction” error and transaction scope
- How do I safely store database login and password in a C# application?
- Passing array to a SQL Server Stored Procedure
- Bulk Insert Sql Server millions of record