No snippets found. Try "React", "PHP", "Django", etc.
HTML
For static HTML pages where inline JavaScript is acceptable.
<script>document.write(new Date().getFullYear())</script>
JavaScript / TypeScript
For use in JS/TS code where you need the year as a value.
new Date().getFullYear()
React / JSX
For use inside JSX templates.
{new Date().getFullYear()}
Next.js
For Next.js pages and components.
{new Date().getFullYear()}
Vue
For use inside Vue templates.
{{ new Date().getFullYear() }}
Svelte
For use inside Svelte templates.
{new Date().getFullYear()}
PHP / WordPress
For PHP templates and pages.
<?php echo date("Y"); ?>
Ruby / ERB
For Ruby on Rails views and ERB templates.
<%= Time.now.year %>
Python / Jinja
For Django, Flask, and other Jinja-based templates.
{{ now().year }}
Go / Hugo
For Hugo and Go html/template sites.
{{ now.Format "2006" }}
Liquid
For Shopify themes and Jekyll sites.
{{ 'now' | date: '%Y' }}
Twig
For Symfony, Craft CMS, and other Twig-based sites.
{{ "now"|date("Y") }}