Converting To Unix Timestamp - Function to convert standard time format to Unix timestamp

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > VB Programming

Converting To Unix Timestamp - Function to convert standard time format to Unix timestamp

Galahad
I don't know how many of you are familiar with IRC development, but all time/date information are saved in unix time stamp format. Unix timestamp is number of seconds elapsed, since 1st january 1970. Unix timestamp is also used in phpBB forums, and possibly in other bulletin boards. It is very convenient for manipulation, mathematical calculations, and other things...

Use these functions to work with Unix time stamps (this is fully working code, just copy/paste it):

CODE
Option Explicit

Private Type SystemTime
       wYear As Integer
       wMonth As Integer
       wDayOfWeek As Integer
       wDay As Integer
       wHour As Integer
       wMinute As Integer
       wSecond As Integer
       wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
       Bias As Long
       StandardName(32) As Integer
       StandardDate As SystemTime
       StandardBias As Long
       DaylightName(32) As Integer
       DaylightDate As SystemTime
       DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Public Function FromUnixTime(ByVal sUnixTime As Long) As Date
Dim NTime As Date, STime As Date
Dim TZ As TIME_ZONE_INFORMATION
STime = #1/1/1970#
NTime = DateAdd("s", sUnixTime, STime)
GetTimeZoneInformation TZ
NTime = DateAdd("n", -TZ.Bias, NTime)
FromUnixTime = NTime
End Function

Public Function ToUnixTime(ByVal STime As Date) As Long
Dim NTime As Date, sUnix As Date, sUnixTime As Long
Dim TZ As TIME_ZONE_INFORMATION
sUnix = #1/1/1970#
GetTimeZoneInformation TZ
NTime = DateAdd("n", TZ.Bias, STime)
sUnixTime = DateDiff("s", sUnix, NTime)
ToUnixTime = sUnixTime
End Function


I hope this helped someone smile.gif

 

 

 


Reply

iGuest
Would like to see this for VBSCRIPT =) That would really help quite a bit

-Mike

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. vbs convert unix timestamp - 2.76 hr back. (1)
  2. timestamp code unix - 8.84 hr back. (1)
  3. unix date function - 15.08 hr back. (1)
  4. unix timestamp to integer - 17.08 hr back. (1)
  5. vbs date as integer - 19.51 hr back. (1)
  6. php timestamp int - 22.69 hr back. (1)
  7. format unix timestamp - 36.21 hr back. (1)
  8. unix date tz - 36.41 hr back. (1)
  9. vb6 convert date to timestamp - 36.83 hr back. (1)
  10. converting unix time - 37.71 hr back. (1)
  11. convert date timestamp vbs - 49.68 hr back. (2)
  12. function to convert time to seconds unix - 75.44 hr back. (1)
  13. unix date -d options - 87.22 hr back. (1)
  14. unix timestamp - 87.90 hr back. (1)
Similar Topics

Keywords : converting, unix, timestamp, function, convert, standard, time, format, unix, timestamp

  1. Log Function
    (2)


      Looking for converting, unix, timestamp, function, convert, standard, time, format, unix, timestamp

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for converting, unix, timestamp, function, convert, standard, time, format, unix, timestamp

*MORE FROM TRAP17.COM*
Similar
Log Function
advertisement



Converting To Unix Timestamp - Function to convert standard time format to Unix timestamp



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE