Help with formatting labels on Time Slider?

1619
3
Jump to solution
05-13-2016 08:50 AM
NMWater
New Contributor III

Hi all,

I was wondering if anyone knows how to format the date in the "daterange" of the Time Slider. I want it to state:

Month Year". My input data was formatted using YYYYMM. Currently, I just get years.

Thanks for all your help!

0 Kudos
1 Solution

Accepted Solutions
TomSellsted
MVP Regular Contributor

NM Water,

I use the dojo/date/locale module.  That allows you to format the date the way you would like.  here is an example:

                //add labels for every other time stop
                var labels = arrayUtil.map(timeSlider.timeStops, function(timeStop, i) {
                    if (i % 2 === 0) {
                        return locale.format(timeStop, {
                            datePattern: 'MMYY',
                            selector: 'date'
                        });
                    } else {
                        return "";
                    }
                });

Regards,

Tom

View solution in original post

0 Kudos
3 Replies
TomSellsted
MVP Regular Contributor

NM Water,

I use the dojo/date/locale module.  That allows you to format the date the way you would like.  here is an example:

                //add labels for every other time stop
                var labels = arrayUtil.map(timeSlider.timeStops, function(timeStop, i) {
                    if (i % 2 === 0) {
                        return locale.format(timeStop, {
                            datePattern: 'MMYY',
                            selector: 'date'
                        });
                    } else {
                        return "";
                    }
                });

Regards,

Tom

0 Kudos
NMWater
New Contributor III

Thanks Tom! This fixed the issue.

However, I have another one now:

My date range in my rest services indicate:

  • [1984/01/01 00:00:00 UTC, 2013/01/01 00:00:00 UTC]

However on my slider the first date being displayed is December of 1983 and the last date is November 2013. it's shifting the time intervals by one month. Have you ever encountered this before?

Best,

Francisco

0 Kudos
TomSellsted
MVP Regular Contributor

Francisco,

I have not seen that problem before.  I see that you are expressly setting your timeExtent too.  Which version of the the JSAPI are you using?

Regards,

Tom

0 Kudos