0

I have a date feild in my data and when I add it to an info window, it shows in zulu time (2017-11-06T00:00:00.000). Is there a way to format the cartoCSS and HTML so that only the date, and not the time, shows?

2

Unfortunately, it is not possible to format the date within the inforwindow code.

You would need to create a new filed in your dataset and populated it by inserting the dates in the format that you want as text. Then, you would need to add that new formatted field in the infowindow code to display it without the timestamp.

In order to transform the date format to text and format the output date, you would need to use the to_char() method which is defined in this section of the postgresql documentation. Where you can find also the different options to format your date fileds as text.

| improve this answer | |
0

Same question a year later brought me be back here, so if you need a quick answer, you have to make a new field, as Oriol said. Here is quick SQL code on how to do that from within the carto data SQL viewer:

update tablename
set stringfield = to_date(cast(datefield as TEXT),'YYYY-MM-DD') 

Format accordingly using the link provided above: https://www.postgresql.org/docs/9.5/static/functions-formatting.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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