• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "date"
    Differences between revisions 3 and 11 (spanning 8 versions)
    Revision 3 as of 2013-11-20 21:08:26
    Size: 990
    Editor: tech
    Comment:
    Revision 11 as of 2015-08-19 21:37:29
    Size: 2878
    Editor: Inanna
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 1: Line 1:
    = Function =
    '''date([timestamp])'''
    == date() ==
    Line 4: Line 3:
    returns string - timestamp is an optional parameter. if timestamp is omitted, current timestamp is used. This function returns the Date object. You may optionally use a timestamp with this function in the format date(timestamp). If timestamp is not supplied then the current timestamp is used. The timestamp is the number of milliseconds that have passed since January 1st, 1970 at 00:00:00.
    Line 6: Line 5:
    == examples ==
    '''date()''' returns current time/date in human readable formatted string:
    The bot will internally apply the toString() method to it when date() is used in a manner that should return a string, for example ''echo date()''.<<BR>>If used in a method that would need a number, for example ''x = date() / 1000'' then the bot will internally apply the toNumber() method to it.
    Line 9: Line 7:
    Mon Oct 21 02:10:26 GMT-0500 2013 '''Example:'''
     . echo date() // returns current time/date in human readable formatted string:
    Line 11: Line 10:
    '''date(timestamp)'''  . ''Result:''
     . Mon Oct 21 02:10:26 GMT-0500 2013
    Line 13: Line 13:
    returns time/date in human readable formatted string for specified timestamp '''Example:'''
     . echo date(1418253379677) //
    returns time/date in human readable formatted string for specified timestamp:
    Line 15: Line 16:
    == related functions ==
    '''date().getTime()'''
     . ''Result:''
     . Wed Dec 10 18:16:19 GMT-0500 2014
    Line 18: Line 19:
    returns current timestamp (integer number). '''Example:'''
     . current = date() // find the time elapsed between script start and script end
     . sleep 30 // just adding some time in between...
     . elapsed = floor((date() - current) / 1000) // dividing by 1000 because we want seconds not milliseconds
     . echo "Time passed is " + elapsed + " seconds."
    Line 20: Line 25:
    timestamp is milliseconds since January 1st 1970 at 00:00:00  . ''Result:''
     . Debug on
     . Starting script
     . Running line 1
     . current = Wed Dec 10 18:24:00 GMT-0500 2014
     . Running line 2
     . Sleeping 30 seconds until 06:24:30 PM
     . Running line 3
     . elapsed = 32
     . Running line 4
     . Time passed is 32 seconds. // 30 seconds of sleep + a couple seconds of script run time
    Line 22: Line 37:
    '''date(timestamp).getHours()''' == Methods to use with date() ==
    Line 24: Line 39:
    returns hour (integer number) for specified timestamp (or current time if timestamp is omitted). '''date().getTime()''' //returns current timestamp as a number rather than string as shown above.
    Line 26: Line 41:
    '''date(timestamp).getMinutes()''' '''date(timestamp).getMonth()''' // returns the month (integer number) for specified timestamp (or current time if timestamp is omitted). It starts counting at 0 for January and ends at 11 for December.
    Line 28: Line 43:
    returns minutes (integer number) for specified timestamp (or current time if timestamp is omitted). '''date(timestamp).getDate()''' // returns the day of the month (integer number) for specified timestamp (or current time if timestamp is omitted). 
    Line 30: Line 45:
    '''date(timestamp).getSeconds()''' '''date(timestamp).getDay()''' // returns the day of the week (integer number) for specified timestamp (or current time if timestamp is omitted). It starts counting at 0 for Sunday and ends at 6 for Saturday.
    Line 32: Line 47:
    returns seconds (integer number) for specified timestamp (or current time if timestamp is omitted). '''date(timestamp).getFullYear()''' // returns the year (integer number) for specified timestamp (or current time if timestamp is omitted).

    '''date(timestamp).getHours()''' // returns hour (integer number) for specified timestamp (or current time if timestamp is omitted).

    '''date(timestamp).getMinutes()''' // returns minutes (integer number) for specified timestamp (or current time if timestamp is omitted).

    '''date(timestamp).getSeconds()''' // returns seconds (integer number) for specified timestamp (or current time if timestamp is omitted).

    date()

    This function returns the Date object. You may optionally use a timestamp with this function in the format date(timestamp). If timestamp is not supplied then the current timestamp is used. The timestamp is the number of milliseconds that have passed since January 1st, 1970 at 00:00:00.

    The bot will internally apply the toString() method to it when date() is used in a manner that should return a string, for example echo date().
    If used in a method that would need a number, for example x = date() / 1000 then the bot will internally apply the toNumber() method to it.

    Example:

    • echo date() // returns current time/date in human readable formatted string:
    • Result:

    • Mon Oct 21 02:10:26 GMT-0500 2013

    Example:

    • echo date(1418253379677) // returns time/date in human readable formatted string for specified timestamp:
    • Result:

    • Wed Dec 10 18:16:19 GMT-0500 2014

    Example:

    • current = date() // find the time elapsed between script start and script end
    • sleep 30 // just adding some time in between...
    • elapsed = floor((date() - current) / 1000) // dividing by 1000 because we want seconds not milliseconds
    • echo "Time passed is " + elapsed + " seconds."
    • Result:

    • Debug on
    • Starting script
    • Running line 1
    • current = Wed Dec 10 18:24:00 GMT-0500 2014
    • Running line 2
    • Sleeping 30 seconds until 06:24:30 PM
    • Running line 3
    • elapsed = 32
    • Running line 4
    • Time passed is 32 seconds. // 30 seconds of sleep + a couple seconds of script run time

    Methods to use with date()

    date().getTime() //returns current timestamp as a number rather than string as shown above.

    date(timestamp).getMonth() // returns the month (integer number) for specified timestamp (or current time if timestamp is omitted). It starts counting at 0 for January and ends at 11 for December.

    date(timestamp).getDate() // returns the day of the month (integer number) for specified timestamp (or current time if timestamp is omitted).

    date(timestamp).getDay() // returns the day of the week (integer number) for specified timestamp (or current time if timestamp is omitted). It starts counting at 0 for Sunday and ends at 6 for Saturday.

    date(timestamp).getFullYear() // returns the year (integer number) for specified timestamp (or current time if timestamp is omitted).

    date(timestamp).getHours() // returns hour (integer number) for specified timestamp (or current time if timestamp is omitted).

    date(timestamp).getMinutes() // returns minutes (integer number) for specified timestamp (or current time if timestamp is omitted).

    date(timestamp).getSeconds() // returns seconds (integer number) for specified timestamp (or current time if timestamp is omitted).


    CategoryFunctions

    date (last edited 2015-08-19 21:37:29 by Inanna)