Get timestamp of request

Feature Idea (one per thread):

Get a timestamp of the issued server request

Issue that it solves:

Inside a component, we're using a copyright field and it would be nice if the YEAR gets automatically updated based on the time (year) it was issued. The date should come from the server --> prismic request.

Is that already possible? Would like to avoid setting up a custom server (currently using next.js). Thanks!

Hi Andi,

Thanks for submitting the idea.

To help me understand fully, is there any reason you couldn't use the year from first publication date of a document to populate the copyright field?

https://prismic.io/docs/technologies/the-response-object-javascript

Thanks.

Hi @Phil ,

thanks for getting back. The first_publication_date will not help here unfortunately. I have the copyright field on my website and I'd like to avoid the manual update from year 2021 to 2022 once every year - so getting the time of the request would help to automate that.

Why wouldn't you just use JavaScript Date Objects?

I know a build would need to be triggered to get the latest date, but if your website is being updated regularly it shouldn't be an issue.

@Phil The Date object is client side and might cause reliability-issues - which can be read here.

Therefore a Server Time - preferrably by the request to prismic - would be superb.

That's totally fair, I see why that wouldn't work now.

I've submitted this as a feature request in the tracker so the @features-team can check this out.

In the meantime a request to the World Clock API might be a good workaround for you:
http://worldclockapi.com/

@Phil thanks for the suggestion! will def check that out :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.