Scott
Scott

Reputation: 6251

Getting unix timestamp

Its a pretty simple question but I couldnt find nothing about it.

I would like to get the current unix timestamp in seconds, I would like to get the identical result as the PHP's time() function.

System.Now returns full date with the current time.

How can I achieve this in vb.net?

Upvotes: 0

Views: 6621

Answers (1)

Rolf Bjarne Kvinge
Rolf Bjarne Kvinge

Reputation: 19345

I belive this will do it:

Public Shared Function GetUnixTimestamp () As Double
    Return (DateTime.Now - new DateTime (1970, 1, 1, 0, 0, 0, 0)).TotalSeconds
End Function

Upvotes: 2

Related Questions