Show current time merge field

Simon Parker
edited January 12, 2018 in Questions
Hi - we have a dynamic SKUID dashboard with a snippet refreshing the page every 5 minutes. We would like to show the current time at each refresh - something like 'Last Updated : xxxxxxx'.

I tried by adding a template at top of the page, with the following in the HTML:
Last Updated : {{$System.Now}}

but that didn't work. I have checked through the listed merge variables:

but don't see System listed. Any ideas as to how to pull in the date & time ?


  • Simon Parker
    edited March 26, 2015
    As an updated I tried creating a formula field with value = NOW, then pulling that into the model and adding that to the template. But as the template is set to 'Do not run on each row' I guess that is stopping it from working.
  • Simon Parker
    edited March 26, 2015
    Looks like I answered my own question (again..)

    as I already had snippet running to do the refresh, I added code to get the date/time and insert into the appropriate element on the page:
                var currentTime = new Date();                          var month = currentTime.getMonth() + 1;
                var day = currentTime.getDate();
                var year = currentTime.getFullYear();
                var yearstring = day + "/" + month + "/" + year;
                var hours = currentTime.getHours()
                var minutes = currentTime.getMinutes()
                if (minutes < 10){
                    minutes = "0" + minutes;
                var templatetext = 'Last updated : '+hours + ':' + minutes + ' ' + yearstring;
                var elements = document.getElementById('currenttime').getElementsByTagName('*');
                elements[1].innerHTML = templatetext;
  • Chris
    edited January 12, 2018

    I've had similar issues of needing to present values up to a template (or elsewhere) via mustache.  The little trick I use is to fake it as a URL parameter, such as: = new Date().toLocaleTimeString()  
    This puts the value into in the $Param variable, which can then be accessed in a template (or elsewhere that mustache is supported) via something like:
    Last updated: {{$Param.LastTime}}
    I'd love it we had a more official way to pass values up to mustache, but I've not found it yet.

    Also - for formatting the date / time - here is a short hand I have used...
    new Date().toLocaleTimeString() + ' on ' + skuid.$.datepicker.formatDate(skuid.utils.userLocale.dateFormat, new Date())
    which outputs something like
    7:46:44 AM on 3/26/2015
    So the final (hack) string to do it all is... = new Date().toLocaleTimeString() + ' on ' + skuid.$.datepicker.formatDate(skuid.utils.userLocale.dateFormat, new Date());
    - Chris
  • Rob Hatch
    Rob Hatch 🛠️ 
    edited September 1, 2016
    We like a good hack every once in a while.  Yours is a good one. 
  • Jack Sanford
    Jack Sanford San Antonio, TX 💎💎
    edited May 25, 2016
    I like this a lot, I just need the reverse - .toLocaleDateString works great for my date, but the .toLocaleTimeString adds seconds to the time, which makes it not work for my date/time field I'm trying to send data to through my URL

    I'm trying to use .formatTime ("h:mm a", new Date()) but it just crashes no matter what I try

    e.g. = new Date().formatTime ("h:mm a", skuid.time.getSFDateTime) or = skuid.time.getSFDateTime().formatTime ("h:mm a", new Date()) 

    i just don't know how to add the formatTime function...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!