.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> DateTime >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Format unix timestamp to DateTime Object

Posted By:Amit Mehra       Posted Date: November 23, 2009    Points: 10    Category: DateTime    URL: http://www.dotnetspark.com  
 

Format unix timestamp to DateTime Object.

This function will return you human readable datetime from Unix timestamp. Below method will accept double as input parameter and return you DateTime object.

In C# Code sample

///


/// Format Unix time to .NET datetime format
///

///
///
public static DateTime FormatUnixTime(double timestamp)
{
DateTime startUnixTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return startUnixTime.AddSeconds(timestamp);
}

In VB.NET Code Example

'''


''' Format Unix time to .NET datetime format
'''

'''

'''

Public Shared
Function FormatUnixTime(ByVal timestamp As Double) As DateTime
Dim
startUnixTime As New DateTime(1970, 1, 1, 0, 0, 0, 0)
Return
startUnixTime.AddSeconds(timestamp)
End
Function

Thanks
Amit


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend