Hi,

how can I output a current / actual timestamp on site which is not cached?

I'm working with Drupal 8, if I put in a timestamp in twig it only refreshes after cache rebuild.

Thanks

Comments

Michael-IDA’s picture

Template? As in xyz.tpl.php?

Use:
<?php print(Date("Y")); ?>

Format date as desired.

# # #

Or am I misunderstanding your question?

Best,
Michael

Drupal Hosting

NIH Cancer Study: Supplemention with both vitamins and fenbendazole exhibited significant (P = 0.009) inhibition of tumor growth.

uwe_k’s picture

Thanks for your reply.

I'm on Drupal 8.0.6 and in the Twig template i get timestamp with

{{ date().getTimestamp }}

or

{{ 'now'|date('U') }}

and if cache is enabeled the timestamp is also cached and old timestamp is displayed on the site.

My question is, is there a way and what is the recommended way to pass a calculated value to users browser in Drupal 8?

Best,
Uwe