Page 1 of 1

Posted: Tue Nov 26, 2002 2:57 pm
by BackupUser
Restored from previous forum. Originally posted by stefhan.

hi,

Beginner demo user, I would like to know how to obtain system milliseconds time and date.
Thx.

Posted: Tue Nov 26, 2002 5:51 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.

You use the Win API command GetSystemTime_(time.SYSTEMTIME) see docs on Windows API for more info.. If you're not intersted to get the exact time (i.e. not in milliseconds) you can use the built in Date() command, which have seconds as the smallest time unit. If your interested to get the time (in milliseconds) elapsed since your computer was turned on you can use the API command GetTickCount_().

But since you use the demo version i don't think you can access the API, and since the latest demo binary is from PB 3.30 you haven't got the necessary Date library so you can't test the builtin command either...

Posted: Tue Nov 26, 2002 6:27 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

hello stefhan!
Welcome to PureBasic :wink: - Here is a small example how to get the actual LOCAL system date and time via Win32 API...

Code: Select all

; ------------------------------------------------------------
;
; PureBasic Win32 API - Get System Time & Date - Example File
;
; by MrVainSCL! aka Thorsten   26/Nov/2002    PB v3.40+
;
; ------------------------------------------------------------
;
    Info.SYSTEMTIME                           ; Init API Structure for _SYTEMTIME()
;
; -------- Win32 API Structure --------
;
;   typedef struct _SYSTEMTIME   
;     WORD wYear
;     WORD wMonth 
;     WORD wDayOfWeek 
;     WORD wDay 
;     WORD wHour 
;     WORD wMinute 
;     WORD wSecond 
;     WORD wMilliseconds 
;   SYSTEMTIME; 
;
; ------------------------------------------------------------
;
    GetLocalTime_(Info)                       ; Get acutal LOCAL Time by System
    ;
    ; -------- Get actual Date --------
    ;
    cday$       = Str((Info\wDay))
    cmonth$     = Str((Info\wMonth))
    cyear$      = Str((Info\wYear))
    cwday$      = Str((Info\wDayOfWeek))
    ;
    ; -------- Get Actual Time --------
    ; 
    chour$      = Str((Info\wHour)) 
    cminute$    = Str((Info\wMinute))
    csecond$    = Str((Info\wSecond))
    cmillisec$  = Str((Info\wMilliseconds)) 
    ;
    ; -------- Select cwday$ num to get correct weekday --------
    ;
    Select cwday$                           ; Same num handling like in Excel :wink:
      Case "1" : cweekday$ = "Monday" 
      Case "2" : cweekday$ = "Thursday"
      Case "3" : cweekday$ = "Wednesday"
      Case "4" : cweekday$ = "Thursday"
      Case "5" : cweekday$ = "Friday"
      Case "6" : cweekday$ = "Saturday"
      Case "0" : cweekday$ = "Sunday"       
    EndSelect 
    ;
    ; -------- Write results into one string --------
    ;  
    actdate$ = cweekday$ + ", " + cday$ + "-" + cmonth$ + "-" + cyear$ 
    acttime$ = chour$ + ":" + cminute$ + ":" + csecond$ + " and " + cmillisec$ + " millisconds"
    ;
    ; -------- Print the result to the user --------
    ;    
    MessageRequester("Actual Date:",actdate$,0)
    MessageRequester("Actual Time:",acttime$,0)
End
;
; ------------------------------------------------------------



PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Tue Nov 26, 2002 7:49 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.

The source including executeable example can now be found at:
http://www.reelmediaproductions.com/pb/ ... ppets.html


PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten

Posted: Wed Nov 27, 2002 10:16 am
by BackupUser
Restored from previous forum. Originally posted by stefhan.

Thank you !!!