Announcement

Collapse
No announcement yet.

PB-CGI - Date, Time and Unix time stamps.

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

  • PB-CGI - Date, Time and Unix time stamps.

    Here is a small example for PluriBASIC's PB-CGI that can also be compiled to PHP:

    Code:
    [FONT=Courier New][B][COLOR=Blue]#COMPILE[/COLOR] [COLOR=Black]exe[/COLOR]
    [COLOR=Blue]#DIM[/COLOR] [COLOR=Blue]ALL[/COLOR]
    [COLOR=Blue]#REPORT[/COLOR] [COLOR=Blue]NONE[/COLOR]
    [COLOR=Blue]#ENCODE[/COLOR] [COLOR=Black]NO[/COLOR]
    [COLOR=Blue]#PROJECT[/COLOR] [COLOR=DarkGreen]"windows"[/COLOR]
    [COLOR=Blue]#FTPLOC[/COLOR]  [COLOR=DarkGreen]"examples"[/COLOR]
    [COLOR=Blue]#VERSION[/COLOR] [COLOR=Blue]AUTO[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]5.00.6.164674[/COLOR]
    
    [COLOR=Blue]#DATABASE[/COLOR] [COLOR=Blue]CLOSED[/COLOR]
    
    [COLOR=Blue]FUNCTION[/COLOR] [COLOR=Black]PBMAIN()[/COLOR] [COLOR=Blue]AS[/COLOR] [COLOR=Blue]LONG[/COLOR]
    
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"According to this web server...<br>"[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"Today is: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE[/COLOR]([COLOR=DarkGreen]"l, d M Y h:i:s e (T)"[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"With system commands it is: ("[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE$[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=DarkGreen]", "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]TIME$[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=DarkGreen]")"[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"In one hour it will be: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE[/COLOR]([COLOR=DarkGreen]"l, d M Y h:i:s T"[/COLOR][COLOR=Black],[/COLOR] [COLOR=Blue]TIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black])[/COLOR] [COLOR=Black]+[/COLOR] [COLOR=Black]3600[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"In one day it will be: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE[/COLOR]([COLOR=DarkGreen]"l, d M Y h:i:s T"[/COLOR][COLOR=Black],[/COLOR] [COLOR=Blue]TIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black])[/COLOR] [COLOR=Black]+[/COLOR] [COLOR=Black]3600[/COLOR] [COLOR=Black]*[/COLOR] [COLOR=Black]24[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"In one year it will be: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE[/COLOR]([COLOR=DarkGreen]"l, d M Y h:i:s T"[/COLOR][COLOR=Black],[/COLOR] [COLOR=Blue]TIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black])[/COLOR] [COLOR=Black]+[/COLOR] [COLOR=Black]3600[/COLOR] [COLOR=Black]*[/COLOR] [COLOR=Black]24[/COLOR] [COLOR=Black]*[/COLOR] [COLOR=Black]365[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"Unix time stamp is: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]FORMAT$[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]TIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black])[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"User-defined Unix time stamp is: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]FORMAT$[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]MKTIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black]1[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]2[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]3[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]4[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]5[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]2000[/COLOR][COLOR=Black])[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"Which from a local perspective translates to: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]DATE[/COLOR]([COLOR=DarkGreen]"l, d M Y h:i:s T"[/COLOR][COLOR=Black],[/COLOR] [COLOR=Blue]MKTIME[/COLOR][COLOR=Black]([/COLOR][COLOR=Black]1[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]2[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]3[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]4[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]5[/COLOR][COLOR=Black],[/COLOR] [COLOR=Black]2000[/COLOR][COLOR=Black])[/COLOR][COLOR=Black])[/COLOR]
    [COLOR=Blue]PRINTBR[/COLOR] [COLOR=DarkGreen]"Today's Julian date is: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]FORMAT$[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]JULIAN[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]DATE$[/COLOR][COLOR=Black])[/COLOR][COLOR=Black])[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=DarkGreen]" which converts back to: "[/COLOR] [COLOR=Red]&[/COLOR] [COLOR=Blue]GREGORIAN[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]JULIAN[/COLOR][COLOR=Black]([/COLOR][COLOR=Blue]DATE$[/COLOR][COLOR=Black])[/COLOR][COLOR=Black])[/COLOR]
    
    [COLOR=Blue]END[/COLOR] [COLOR=Blue]FUNCTION[/COLOR][/B][/FONT]
    The Output with PowerBASIC is: http://pluribasic.nbson.com/examples/datetime.exe

    The Output with PHP is: http://pluribasic.nbson.com/examples/datetime.php

    There might be small differences with the Timezones but both are correct.
    Last edited by Brian Alvarez; 16 Sep 2016, 01:38 AM. Reason: Corrected a typo.
    www.patreon.com/pluribasic
Working...
X