Announcement

Collapse
No announcement yet.

Display Time

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

  • Display Time

    The Core JavaScript ref has a some date/time functions. Trying to use the Timestring to show the exact time of an event (not the bar time) and not getting anything in the Formula Output window.
    PHP Code:
    function gTime() {
        var 
    time = new Date();
        
    debugPrint(time.toLocaleTimestring());
        return;

    Am I using the toLocaleTimestring function correctly?
    will this give me the event time vs bar time?

  • #2
    Re: Display Time

    pj909
    The syntax you are using for the toLocaleTimestring method is incorrect. See this article in the EFS KnowledgeBase for a complete description and syntax of the Date Object and its methods
    Alex


    Originally posted by pj909
    The Core JavaScript ref has a some date/time functions. Trying to use the Timestring to show the exact time of an event (not the bar time) and not getting anything in the Formula Output window.
    PHP Code:
    function gTime() {
        var 
    time = new Date();
        
    debugPrint(time.toLocaleTimestring());
        return;

    Am I using the toLocaleTimestring function correctly?
    will this give me the event time vs bar time?

    Comment


    • #3
      I must be missing something. That's where I got the syntax.

      Here is what I found in the Knowledge base:
      var today = new Date();
      var s = today.toString();
      and further down were variations of the toString method, specifically:
      toLocaleTimeString() Converts a time to a string using the current locale.
      (e.g.) Returns a string in the format "08:57:04"
      so, it should work, but I'm not getting anything.

      Comment


      • #4
        pj909
        toLocaleTimestring used in your code example should be toLocaleTimeString
        JavaScript is a case sensitive language
        Alex


        Originally posted by pj909
        I must be missing something. That's where I got the syntax.

        Here is what I found in the Knowledge base:

        and further down were variations of the toString method, specifically:


        so, it should work, but I'm not getting anything.

        Comment


        • #5
          I missed that - so did the EFS syntax checker.

          The EFS2 Toolbox and Syntax Checker are great tools. It would be nice if they could be expanded to include all the functions, methods and properties.
          I'll submit that to the suggestion box.

          Comment


          • #6
            pj909
            Actually toLocaleTimestring could be syntactically correct which is why the syntax checker does not report it as an error.
            The method name may not be a valid EFS extension, however to my knowledge it is legal in JavaScript to add custom methods and functions. That type of error would simply be a logic error and the syntax checker does not check for logic errors.
            Alex


            Originally posted by pj909
            I missed that - so did the EFS syntax checker.

            The EFS2 Toolbox and Syntax Checker are great tools. It would be nice if they could be expanded to include all the functions, methods and properties.
            I'll submit that to the suggestion box.

            Comment

            Working...
            X