snipt

Ctrl+h for KB shortcuts

Ruby

current year for copyright

1
2
3
4
5
6
&copy; Copyright <%= current_year -%>.

## Add to application helper
def current_year
    Time.now.strftime('%Y')
end
https://snipt.net/embed/8e3f25eeb97c3ae023e9c85afc74ff8a/
/raw/8e3f25eeb97c3ae023e9c85afc74ff8a/
8e3f25eeb97c3ae023e9c85afc74ff8a
rb
Ruby
7
2019-06-15T06:25:22
True
False
False
/api/public/snipt/2705/
current-year-for-copyright
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="o">&amp;</span><span class="n">copy</span><span class="p">;</span> <span class="no">Copyright</span> <span class="o">&lt;%=</span> <span class="n">current_year</span> <span class="o">-%&gt;.</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1">## Add to application helper</span> </span><span id="L-4"><a name="L-4"></a><span class="k">def</span> <span class="nf">current_year</span> </span><span id="L-5"><a name="L-5"></a> <span class="no">Time</span><span class="o">.</span><span class="n">now</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y&#39;</span><span class="p">)</span> </span><span id="L-6"><a name="L-6"></a><span class="k">end</span> </span></pre></div> </td></tr></table>
rails, ruby, year