0
I am formatting the start date of a list according to the code below, and in the database the dates registered in "2018-11-01" and "2018-11-02" are being listed respectively with the dates in "31/10/2018" and "01/11/2018" on the screen.
frontend code:
{{material.dataInicio | date: 'dd/MM/yyyy' }}
Note: The other dates are correct.
Try it this way:
{{ material.dataInicio | date: 'dd/MM/yyy' | 'UTC' }}
– Sorack
@Sorack, I tried the procedure, but without success.
– aleestevao
What is your version of Angularjs?
– Sorack
@Sorack, the version is 1.7.x
– aleestevao
@Sorack, the thing is, some dates are showing different dates than the ones registered at the base. Examples: 2018-11-01 at the base and on the list 31/10/2018 or at the base 2018-11-02, on the list 01-11-2018. It’s like taking the last day, but other dates, they’re all normal.
– aleestevao
When you give a
console.log(material.dataInicio)
what appears on the console?– Sorack
My guess is that time zone configured in the bank is not the same as the frontend, hence the difference (guess based on nothing, because I do not know how the angular works with dates). If you please [Edit] the question putting the field types, both in the bank and in the frontend, in addition to the values and the error message you mentioned in the comment below, maybe gives us more clues than can be
– hkotsubo
@hkotsubo, I was able to resolve it through the backend. Using Simpledateformat sdf = new Simpledateformat("dd/MM/yyyy"); I created a private attribute Transient String dataInicioStr; Then I passed this Simpledateformat string => material.setDataInicioStr(sdf.format(material.getDataInicio()); and solved the problem.
– aleestevao