• 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

    Revision 5 as of 2014-12-10 23:30:05

    Clear message

    '''date([timestamp])'''

    Returns the Date object. The timestamp as shown above is an optional parameter. 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 elapsed

    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
    • 32 // 32 seconds have elapsed since the "current" variable was set. 30 seconds of sleep + a couple seconds of script run time.

    Methods to use with date()

    date().getTime() //returns current timestamp (integer number).

    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