Created
          October 20, 2014 01:40 
        
      - 
      
- 
        Save sandcastle/bdf4bf670bd7bd8a64f2 to your computer and use it in GitHub Desktop. 
    To Unix Time from DateTime
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static class TimeExtensions | |
| { | |
| // Good website for conversions: | |
| // http://www.epochconverter.com/ | |
| // ToUnixTime(DateTime.Parse("20/10/2014 12:00:00 AM")) - should equal 1413734400 | |
| public static long ToUnixTime(this DateTime date) | |
| { | |
| return (date.ToUniversalTime().Ticks - 621355968000000000) / 10000000; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Taken from http://stackoverflow.com/questions/2883576/how-do-you-convert-epoch-time-in-c