Expand my Community achievements bar.

Time, The date picker is six hours longer

Avatar

Level 2

我将再次使用 datepicker 在对话框中配置时间。但是我使用了标头 applysTime: 打印出新的 Date (properties.applysTime 的getTime()),并且 “headerpapplysTime”: “2025-03-05T15:14:00.000Z” 比我配置的要长 6 小时。我的配置如下

guodongha_2-1741139654901.png

guodongha_3-1741139697757.png

 

guodongha_1-1741139646250.png

 

7 Replies

Avatar

Level 9

Hi @guodongha 

 

Can you look and share what values you have stored in JCR properties, then what values you have in the JS properties object ?

 

You will need to debug and check what happens with the time value from the moment it is stored in AEM to the point you use it in JS code. I suspect it has something to do with the timezone. You enter a value in the dialog field, but somewhere along the way it sets a timezone (maybe it does it as a default behavior) which makes that time difference of 6 hours.

 

The time values that you see in the page might be UTC times, because I see a 000Z which stands for Zero timezone, meaning 0 offset from the Coordinated Universal Time (UTC). This denotes times are in UTC.

 

Also, I think you will get better help if you write your messages in English.

Avatar

Level 2

In the JCR node, the+8 time zone is displayed. What I don't quite understand is why I added 6 to the 09:14 time after outputting it, which turned it into 15:14guodongha_2-1741161742200.png

 

 

 

Avatar

Level 9

It is not 6h difference. It is actually 8 h difference, that is how much is between 9 am and 15 pm. Which is exactly hot the timestamp says it should be:

Tethich_0-1741163227623.png

 

Try to add a Z at the end of you displayFormat property definition. Something like this:

displatFormat="YYYY-MM-DD HH:mm Z"

 

Avatar

Level 2

that is how much is between 9 am and 15 pm.From 9am to 3pm, it's still 6 hours. I don't quite understand how eight hours come about

Avatar

Level 2
displatFormat="YYYY-MM-DD HH:mm Z"

This should just be about the display format of time! It has nothing to do with the time I configured and the time obtained through the new date, right! The storage time of JCR node is 2025-03-05T09:14:00.0000+08:00, but I converted the time using new Date (properties. activityTime. getTime()); 2025-03-05T15:14:00.000Z; The difference between these two times is six hours, not eight hours

guodongha_0-1741168291985.png

displatformat  add  Z ;Just added display+8:00 as shown in the above picture

Avatar

Level 9

Can you log the value from properties.activitySTime.getTime() to see exactly what is it ?

Avatar

Level 5