I'm new working with cartoDB and I'm trying to show the hour and the date in a torque slider but doesn't work properly and show mm/dd/yyyy instead of mm-dd hh:mm.


"http://libs.cartocdn.com/cartodb.js/v3/3.14/cartodb.js" script "http://libs.cartocdn.com/cartodb.js/v3/3.14/themes/css/cartodb.css" stylesheet

I'm using the following code:

function main() {
   cartodb.createVis('map', 'viz.json', {
        shareable: true,
        title: true,
        description: true,
        search: false,
        tiles_loader: true,
        center_lat: 0,
        center_lon: 0,
        zoom: 10,
        time_slider: true,
    .done(function(vis, layers) {
      var slider = vis.getOverlay('time_slider')
      slider.formatter(function(d) {
        return  d.getUTCMonth()+"-"+ d.getUTCDay() + " "+ d.getUTCHours() + ":"+ d.getUTCMinutes();
    .error(function(err) {
  window.onload = main;

How can I fix it?

1 Answer 1


From 3.12 this has been changed, try with the following code instead:

    return  d.getUTCMonth()+"-"+ d.getUTCDay() + " "+ d.getUTCHours() + ":"+ d.getUTCMinutes();
  • To show the day in format dd is better to use, getUTCDate(), getUTDay() gives instead the day of the week. Commented Jun 9, 2015 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.