Get System Time And Date - Windows

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Get System Time And Date - Windows

Post by BackupUser »

Code updated for 5.20+ (same as Date() and FormatDate())

Restored from previous forum. Originally posted by wayne1.

Code: Select all

;pb windows version

;wYear 
;Specifies the current year. 
;wMonth 
;Specifies the current month; January = 1, February = 2, and so on. 
;wDayOfWeek 
;Specifies the current day of the week; Sunday = 0, Monday = 1, and so on. 
;wDay 
;Specifies the current day of the month. 
;wHour 
;Specifies the current hour. 
;wMinute 
;Specifies the current minute. 
;wSecond 
;Specifies the current second. 
;wMilliseconds 
;Specifies the current millisecond. 

;The wDayOfWeek member of the Time Structure is ignored. 


Structure Time 
  wYear.w ; 
  wMonth.w ; 
  wDayOfWeek.w ; 
  wDay.w ; 
  wHour.w ; 
  wMinute.w ; 
  wSecond.w ; 
  wMilliseconds.w ; 
EndStructure

Dim GetTime.Time(0)


GetSystemTime_(GetTime(0));

Result = MessageRequester("Date", "Today's Date is " + Str(GetTime(0)\wMonth) + "\"+ Str(GetTime(0)\wDay - 1)+ " \"+ Str(GetTime(0)\wYear) ,0)



Edited by - wayne1 on 10 July 2001 04:41:35
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Here is a shorter version, it uses the windows structure SYSTEMTIME (same as you did by hand)

Code: Select all

Info.SYSTEMTIME
GetSystemTime_(Info)
MessageRequester("Date", "Today's Date is " + str(Info\wMonth) + "\"+ str(Info\wDay)+ "\"+ str(Info\wYear) ,0)
Result = MessageRequester("Date", "Today's Date is " + str(GetTime(0)\wMonth) + "\"+ str(GetTime(0)\wDay - 1)+ " \"+ str(GetTime(0)\wYear) ,0)
You get from GetSystemTime always the Greenwich Date/Time, thats why you did:
GetTime(0)\wDay - 1 <- (it depends where you live)





Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You can use GetLocalTime() intead of GetSystemTime() to have the real time, with adjustement...

Fred - AlphaSND
Post Reply