Question : handling gregorian dates

I have the following gregorian date as an example......
1280491173

I need to display that as a user friendly date on screen.

I then allow the user to enter a date to search by, and at this point will need to convert the date back to gregorian date to use to search against the database.

Is there anything built in yet within .net to do this.

Am using framework 2.0.....

Answer : handling gregorian dates

That might be "UNIX Time":
http://en.wikipedia.org/wiki/Unix_time

    "Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds."

Here's a simple example:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim lng As Long
        If Long.TryParse(TextBox1.Text, lng) Then
            Dim dt As DateTime = New DateTime(1970, 1, 1).AddSeconds(lng)
            Label1.Text = dt.ToString
        End If
    End Sub

Your value of "1280491173" came back as "7/30/2010 11:59:33 AM".  Does that seem right?

To go the other way, converting a date to a stamp:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dt As DateTime
        If DateTime.TryParse(TextBox1.Text, dt) Then
            Dim lng As Long = dt.Subtract(New DateTime(1970, 1, 1)).TotalSeconds
            Label1.Text = lng
        End If
    End Sub
Random Solutions  
 
programming4us programming4us