Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Date and Time function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date and Time function

    '
    Code:
    'PBWIN 9.00 - WinApi 05/2008 - XP Pro SP3
    'adapted from http://www.powerbasic.com/support/pb...hlight=weekday
    'by Peter Lameijn 
     
    #Compile Exe
    #Dim All
    #Include "Win32Api.inc"
    '
    Function Full_Date_Time As String
      Local ST As SYSTEMTIME, d, AmPm As String, hr As Long
      GetLocalTime ST 'adjust to local time                   
      d$ = Choose$(ST.wDayOfWeek + 1, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") & ", " '& _
      d$ = d$ & Choose$(ST.wMonth, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") 
      d$ = d$ & Str$(ST.wDay) & "," & Str$(St.wYear)
    '
      AmPm$ = " am" 
    '
      hr = st.Whour
    '
      if Hr > 11 then AmPm$ = " PM" 
    '
      If hr > 12 Then  hr = hr - 12
    '
      d$ = d$ & Using$(" @ #:##", hr,st.Wminute) & AmPm$
    '
      Function = d$
    '
    End Function
    '
    'Sample Use
    Function PBMain () As Long
      ? Full_Date_Time
    End Function                   
    '
    Last edited by Gösta H. Lovgren-2; 9 Feb 2009, 09:43 AM. Reason: Corrected for Noon PM
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/
Working...
X