Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT DateTime to UNIX Timestamp in VB.NET!

Status
Not open for further replies.

steverbs

Programmer
Jul 17, 2003
253
GB
Hi all,

Running into trouble with a deadline here. Does anyone know how I can get the GMT timestamp since the UNIX Epoch? I've seen loads of examples in C#, but not VB.NET.

Regards.

Stephen.
 
Steve

Am I correct in thinking the UNIX Timestamp is just a character string?. I would guess the only way to get the timestamp would be to write a simple VB function?

Remind me of the timestamp format and I'll see what I can do



Sweep
...if it works dont mess with it
 
Thank you for the help Sweep.

Basically, the UNIX timestamp is just the number of seconds (though it is often the milliseconds that are counted) that have occured since 1st January 1970 (UNIX Epoch). I think its about 10 characters long now.

See here:
Regards.

Stephen.
 
Try this:
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim ts As TimeSpan = DateTime.op_Subtraction(DateTime.Now, New DateTime(1970, 1, 1, 0, 0, 0))

        MessageBox.Show(ts.TotalSeconds)

    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top