snipt

Ctrl+h for KB shortcuts

PHP

PHP: Get timestamp First day of the month (or last)

1
2
3
4
<?php

$tsFirstDayOfMonth = strtotime('first day of '.date('F Y'));
$tsLastDayOfMonth  = strtotime('last day of '.date('F Y'));
https://snipt.net/embed/fd5716b81a211fef6b91201bf874aa94/
/raw/fd5716b81a211fef6b91201bf874aa94/
fd5716b81a211fef6b91201bf874aa94
php
PHP
4
2016-12-28T21:12:39
True
False
True
Nov 19, 2012 at 10:38 AM
/api/public/snipt/50461/
php-get-timestamp-first-day-of-the-month-or-last
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nv">$tsFirstDayOfMonth</span> <span class="o">=</span> <span class="nb">strtotime</span><span class="p">(</span><span class="s1">&#39;first day of &#39;</span><span class="o">.</span><span class="nb">date</span><span class="p">(</span><span class="s1">&#39;F Y&#39;</span><span class="p">));</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$tsLastDayOfMonth</span> <span class="o">=</span> <span class="nb">strtotime</span><span class="p">(</span><span class="s1">&#39;last day of &#39;</span><span class="o">.</span><span class="nb">date</span><span class="p">(</span><span class="s1">&#39;F Y&#39;</span><span class="p">));</span> </span></pre></div> </td></tr></table>
date, php, timestamp