Amphtml: is it a way in AMP to get current date and its timezone ? example (GMT+0800)

Created on 5 Mar 2018  路  2Comments  路  Source: ampproject/amphtml

in javascript, we can write something likenew Date().toTimeString();
and it will display "17:08:21 GMT+0800 (CST)"

is there any component/ way that we can use to get similar result related to above ?

DiscussioQuestion

Most helpful comment

@leonalicious Do you need the data for display on the client-side or to send to the server?

If client-side, amp-bind currently does not support date. Please subscribe to the FR https://github.com/ampproject/amphtml/issues/11901.

If need this data to send to server, you can get TIMEZONE and TIMESTAMP via variable substitution ( https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md#device-and-browser ).

Hope this helps.

All 2 comments

@leonalicious Do you need the data for display on the client-side or to send to the server?

If client-side, amp-bind currently does not support date. Please subscribe to the FR https://github.com/ampproject/amphtml/issues/11901.

If need this data to send to server, you can get TIMEZONE and TIMESTAMP via variable substitution ( https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md#device-and-browser ).

Hope this helps.

Closing the issue since dup of #11901 and server-side workaround documented above.

Was this page helpful?
0 / 5 - 0 ratings