snipt

Ctrl+h for KB shortcuts

Text only

PHP script file last modification data

//echo script file last modification data
echo date('d/m/y',filemtime($_SERVER['SCRIPT_FILENAME'])); 
https://snipt.net/embed/78633087d96168b9f9a726fd194b5a0d/
/raw/78633087d96168b9f9a726fd194b5a0d/
78633087d96168b9f9a726fd194b5a0d
text
Text only
2
2019-08-21T08:25:02
True
False
False
/api/public/snipt/8689/
php-script-file-last-modification-data
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>//echo script file last modification data </span><span id="L-2"><a name="L-2"></a>echo date(&#39;d/m/y&#39;,filemtime($_SERVER[&#39;SCRIPT_FILENAME&#39;])); </span></pre></div> </td></tr></table>
date, php

Bash

bash month test

1
2
3
4
[ `date --date='next day' +'%B'` == `date +'%B'` ] || echo 'fim do mês'

# o trecho antes da dupla igualdade retorna o mês do dia de amanhã,
# já o trecho após a dupla igualdade retorna o mês do dia de hoje, caso # # sejam diferentes o bash avisa que você está no fim do mês. 
https://snipt.net/embed/3454d9885b2f554e4a687bd33efe4cf7/
/raw/3454d9885b2f554e4a687bd33efe4cf7/
3454d9885b2f554e4a687bd33efe4cf7
bash
Bash
6
2019-08-21T08:25:45
True
False
False
/api/public/snipt/8626/
bash-month-test
<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="o">[</span> <span class="sb">`</span>date --date<span class="o">=</span><span class="s1">&#39;next day&#39;</span> +<span class="s1">&#39;%B&#39;</span><span class="sb">`</span> <span class="o">==</span> <span class="sb">`</span>date +<span class="s1">&#39;%B&#39;</span><span class="sb">`</span> <span class="o">]</span> <span class="o">||</span> <span class="nb">echo</span> <span class="s1">&#39;fim do mês&#39;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1"># o trecho antes da dupla igualdade retorna o mês do dia de amanhã,</span> </span><span id="L-4"><a name="L-4"></a><span class="c1"># já o trecho após a dupla igualdade retorna o mês do dia de hoje, caso # # sejam diferentes o bash avisa que você está no fim do mês. </span> </span></pre></div> </td></tr></table>
bash, date

PHP

Regex: Date format

1
2
3
4
<?
// Date must match format: mm/dd/yyyy
if (!preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $due_date))
  echo "Error !";
https://snipt.net/embed/3e949a4ab92f4abbfa3cc0ef86099bc4/
/raw/3e949a4ab92f4abbfa3cc0ef86099bc4/
3e949a4ab92f4abbfa3cc0ef86099bc4
php
PHP
4
2019-08-21T08:26:06
True
False
False
/api/public/snipt/8292/
regex-date-format
<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;?</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// Date must match format: mm/dd/yyyy</span> </span><span id="L-3"><a name="L-3"></a><span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">preg_match</span><span class="p">(</span><span class="s1">&#39;/^\d{2}\/\d{2}\/\d{4}$/&#39;</span><span class="p">,</span> <span class="nv">$due_date</span><span class="p">))</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">echo</span> <span class="s2">&quot;Error !&quot;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
date, php, regex

C#

DateTime in format YYYYMMDD as String

DateTimeVariable.ToString("yyyyMMdd")
https://snipt.net/embed/7f488663e385be08ea36a24a5f5e8de5/
/raw/7f488663e385be08ea36a24a5f5e8de5/
7f488663e385be08ea36a24a5f5e8de5
csharp
C#
1
2019-08-21T08:26:22
True
False
False
/api/public/snipt/7998/
fecha-en-formato-string-yyyymmdd-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">DateTimeVariable</span><span class="p">.</span><span class="n">ToString</span><span class="p">(</span><span class="s">&quot;yyyyMMdd&quot;</span><span class="p">)</span> </span></pre></div> </td></tr></table>
c#, date
https://snipt.net/embed/7f343bf9ac4a240106eb9c05fccbe3a7/
/raw/7f343bf9ac4a240106eb9c05fccbe3a7/
7f343bf9ac4a240106eb9c05fccbe3a7
text
Text only
1
2019-08-21T08:26:50
True
False
False
/api/public/snipt/7515/
my-preferred-php-date-format-which-is-4-digit-year-dot-2-digit-month-2-digit-day-dot-2-digit-hour-military-time-2-digit-minute
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Y\.md\.Hi </span></pre></div> </td></tr></table>
date, php

Bash

Shows svn check ins for a specific user in a certain date range.

$ svn log -r {2009-07-09}:{2007-08-17}  | grep -a3 <username>
https://snipt.net/embed/401c7821dc62f278d5f07f55a06e0469/
/raw/401c7821dc62f278d5f07f55a06e0469/
401c7821dc62f278d5f07f55a06e0469
bash
Bash
1
2019-08-21T08:27:12
True
False
False
/api/public/snipt/7334/
shows-svn-check-ins-for-a-specific-user-in-a-certain-date-range
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ svn log -r <span class="o">{</span>2009-07-09<span class="o">}</span>:<span class="o">{</span>2007-08-17<span class="o">}</span> <span class="p">|</span> grep -a3 &lt;username&gt; </span></pre></div> </td></tr></table>
date, log, range, svn, username

PHP

Convert input to MySQL datetime.

1
2
3
<?php
date('Y-m-d H:i:s', strtotime($_POST['birthday']));
?>
https://snipt.net/embed/80e597aef3f84a2accb3143736df9470/
/raw/80e597aef3f84a2accb3143736df9470/
80e597aef3f84a2accb3143736df9470
php
PHP
3
2019-08-21T08:27:56
True
False
False
/api/public/snipt/7237/
convert-input-to-mysql-datetime
<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></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 class="nb">date</span><span class="p">(</span><span class="s1">&#39;Y-m-d H:i:s&#39;</span><span class="p">,</span> <span class="nb">strtotime</span><span class="p">(</span><span class="nv">$_POST</span><span class="p">[</span><span class="s1">&#39;birthday&#39;</span><span class="p">]));</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
date, datetime, mysql, php, strtotime

HTML

Well Formed Meta Tags

1
2
3
4
5
6
7
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="abstract" content="" />
<meta http-equiv="last-modified" content="Mon, 1 Jan 2009 12:00:00 -0700" />
https://snipt.net/embed/159c78dafb1bf447d9c564a72537223d/
/raw/159c78dafb1bf447d9c564a72537223d/
159c78dafb1bf447d9c564a72537223d
html
HTML
7
2019-08-22T05:34:35
True
False
False
/api/public/snipt/7211/
well-formed-meta-tags
<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> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">&quot;Content-Script-Type&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span> <span class="p">/&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">&quot;Content-Style-Type&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;text/css&quot;</span> <span class="p">/&gt;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">&quot;Content-Type&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;text/html; charset=UTF-8&quot;</span> <span class="p">/&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;keywords&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;&quot;</span> <span class="p">/&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;description&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;&quot;</span> <span class="p">/&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;abstract&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;&quot;</span> <span class="p">/&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">&quot;last-modified&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;Mon, 1 Jan 2009 12:00:00 -0700&quot;</span> <span class="p">/&gt;</span> </span></pre></div> </td></tr></table>
date, head, meta