Skip to content

Conversation

@nishanths
Copy link
Contributor

@nishanths nishanths commented Dec 31, 2016

Add a timeNow template function that returns the current time as
time.Time. Also, update related docs.

Don't know what the right way to test this change is (if necessary), so I'm open to suggestions.

Personally, I'm looking to use use the unix timestamp of the current time in the query string for cache busting in a theme.

<link rel="stylesheet" href="/css/reset.css?t={{ timeNow.Unix }}">

I'm sure hugo users will come up with other creative uses for current time.

@CLAassistant
Copy link

CLAassistant commented Dec 31, 2016

CLA assistant check
All committers have signed the CLA.

@nishanths nishanths changed the title tpl: add timeNowUTC Dec 31, 2016
@moorereason
Copy link
Contributor

time.Now is already accessible on the Page object.

However, I've started a discussion referencing this PR: https://discuss.gohugo.io/t/4968

@nishanths nishanths changed the title tpl: add timeNow Dec 31, 2016
@nishanths
Copy link
Contributor Author

Updated the function name to now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this fits fine next to time, but the rest of them are alphabetic ordered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

Add a now template function that returns the current time as time.Time.
Also, update related docs.
@bep bep merged commit cabc6b3 into gohugoio:master Jan 1, 2017
@nishanths nishanths deleted the time-now-utc branch January 1, 2017 09:58
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants