snipt

Ctrl+h for KB shortcuts

Bash

Convert epoch to Human Readable date

date -d @1365063840
Thu Apr  4 10:24:00 CEST 2013
https://snipt.net/embed/c5dc3f9efda88320e8a6a20de2e82b1a/
/raw/c5dc3f9efda88320e8a6a20de2e82b1a/
c5dc3f9efda88320e8a6a20de2e82b1a
bash
Bash
2
2019-06-17T03:21:53
True
False
False
Apr 04, 2013 at 05:04 AM
/api/public/snipt/58775/
convert-epoch-to-human-readable-date
<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>date -d @1365063840 </span><span id="L-2"><a name="L-2"></a>Thu Apr <span class="m">4</span> 10:24:00 CEST 2013 </span></pre></div> </td></tr></table>
date, unix

PHP

Prendere nome mese dal numero

1
2
3
<?php
$nav_title = date("F", mktime(0, 0, 0, $mese, 10));
?>
https://snipt.net/embed/ebe88182ca9a70b904dc524b409f56c7/
/raw/ebe88182ca9a70b904dc524b409f56c7/
ebe88182ca9a70b904dc524b409f56c7
php
PHP
3
2019-06-04T11:36:30
True
False
False
Mar 25, 2013 at 05:26 PM
/api/public/snipt/58259/
prendere-nome-mese-dal-numero
<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="nv">$nav_title</span> <span class="o">=</span> <span class="nb">date</span><span class="p">(</span><span class="s2">&quot;F&quot;</span><span class="p">,</span> <span class="nb">mktime</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">$mese</span><span class="p">,</span> <span class="mi">10</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, format, php

JavaScript

jQuery DatePicker Date Validation

1
2
3
4
5
6
7
var selectedDate = $('#datepicker').datepicker('getDate');
var now = new Date();
if (selectedDate < now) {
  // selected date is in the past
}

//http://stackoverflow.com/questions/8305259/check-if-date-is-in-the-past-javascript
https://snipt.net/embed/fc2b5b9565f1a120ebc44b483913070a/
/raw/fc2b5b9565f1a120ebc44b483913070a/
fc2b5b9565f1a120ebc44b483913070a
js
JavaScript
7
2019-06-14T02:08:54
True
False
False
/api/public/snipt/54304/
jquery-datepicker-date-validation
<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="kd">var</span> <span class="nx">selectedDate</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#datepicker&#39;</span><span class="p">).</span><span class="nx">datepicker</span><span class="p">(</span><span class="s1">&#39;getDate&#39;</span><span class="p">);</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">var</span> <span class="nx">now</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="k">if</span> <span class="p">(</span><span class="nx">selectedDate</span> <span class="o">&lt;</span> <span class="nx">now</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="c1">// selected date is in the past</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c1">//http://stackoverflow.com/questions/8305259/check-if-date-is-in-the-past-javascript</span> </span></pre></div> </td></tr></table>
date, datepicker, jquery, validation

Text only

phpmyadmin Database filename patterns

__DB___%Y-%m-%d-%H:%m   // Gives MYDATABASE_2012-12-22-02:12.sql
https://snipt.net/embed/c1d23bc6519a26de344d71d11f7533c4/
/raw/c1d23bc6519a26de344d71d11f7533c4/
c1d23bc6519a26de344d71d11f7533c4
text
Text only
1
2019-06-03T05:53:09
True
False
False
Dec 21, 2012 at 07:39 PM
/api/public/snipt/52210/
phpmyadmin-database-filename-patterns
<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>__DB___%Y-%m-%d-%H:%m // Gives MYDATABASE_2012-12-22-02:12.sql </span></pre></div> </td></tr></table>
date, phpmyadmin php

Bash

Set date & time on OpenVz VPS

1
2
3
4
5
Set date & time on Debian 6 OpenVz container to Spanish time. 

As root: 

cd /etc; rm localtime; ln -s /usr/share/zoneinfo/Europe/Madrid localtime
https://snipt.net/embed/8ed0c5dc36667d3c4812637c6e734529/
/raw/8ed0c5dc36667d3c4812637c6e734529/
8ed0c5dc36667d3c4812637c6e734529
bash
Bash
5
2019-06-09T10:09:14
True
False
False
Dec 06, 2012 at 10:17 AM
/api/public/snipt/51347/
set-date-time-on-openvz-vps
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Set date <span class="p">&amp;</span> <span class="nb">time</span> on Debian <span class="m">6</span> OpenVz container to Spanish time. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>As root: </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="nb">cd</span> /etc<span class="p">;</span> rm localtime<span class="p">;</span> ln -s /usr/share/zoneinfo/Europe/Madrid localtime </span></pre></div> </td></tr></table>
OpenVz, date, time

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

VB.net

VB – Aktuelle Kalenderwoche

1
2
3
4
Function KW(d As Date) As Integer
    t = DateSerial(Year(d + (8 - WeekDay(d)) Mod 7 - 3), 1, 1)
    KW = (d - t - 3 + (WeekDay(t) + 1) Mod 7) \ 7 + 1
End Function
https://snipt.net/embed/1f4cc7b55fa6d265352547115ac928ed/
/raw/1f4cc7b55fa6d265352547115ac928ed/
1f4cc7b55fa6d265352547115ac928ed
vb.net
VB.net
4
2019-05-17T00:37:21
True
False
False
Oct 28, 2012 at 06:40 PM
/api/public/snipt/49227/
vb-aktuelle-kalenderwoche
<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="k">Function</span> <span class="nf">KW</span><span class="p">(</span><span class="n">d</span> <span class="ow">As</span> <span class="kt">Date</span><span class="p">)</span> <span class="ow">As</span> <span class="kt">Integer</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">t</span> <span class="o">=</span> <span class="n">DateSerial</span><span class="p">(</span><span class="n">Year</span><span class="p">(</span><span class="n">d</span> <span class="o">+</span> <span class="p">(</span><span class="mi">8</span> <span class="o">-</span> <span class="n">WeekDay</span><span class="p">(</span><span class="n">d</span><span class="p">))</span> <span class="ow">Mod</span> <span class="mi">7</span> <span class="o">-</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">KW</span> <span class="o">=</span> <span class="p">(</span><span class="n">d</span> <span class="o">-</span> <span class="n">t</span> <span class="o">-</span> <span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">WeekDay</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">Mod</span> <span class="mi">7</span><span class="p">)</span> <span class="o">\</span> <span class="mi">7</span> <span class="o">+</span> <span class="mi">1</span> </span><span id="L-4"><a name="L-4"></a><span class="k">End</span> <span class="k">Function</span> </span></pre></div> </td></tr></table>
date, vb

VB.net

VBScript – Aktuelle Kalenderwoche

1
2
3
4
5
Function KW(myDate) 
Dim t
	t = DateSerial(Year(myDate + (8 - Weekday(myDate)) Mod 7 - 3), 1, 1)
	KW = (myDate - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1
End Function
https://snipt.net/embed/3e4a6debfa54dad54189524d55b9f2b4/
/raw/3e4a6debfa54dad54189524d55b9f2b4/
3e4a6debfa54dad54189524d55b9f2b4
vb.net
VB.net
5
2019-06-17T19:03:55
True
False
False
/api/public/snipt/49226/
vbscript-aktuelle-kalenderwoche
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">Function</span> <span class="nf">KW</span><span class="p">(</span><span class="n">myDate</span><span class="p">)</span> </span><span id="L-2"><a name="L-2"></a><span class="k">Dim</span> <span class="n">t</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">t</span> <span class="o">=</span> <span class="n">DateSerial</span><span class="p">(</span><span class="n">Year</span><span class="p">(</span><span class="n">myDate</span> <span class="o">+</span> <span class="p">(</span><span class="mi">8</span> <span class="o">-</span> <span class="n">Weekday</span><span class="p">(</span><span class="n">myDate</span><span class="p">))</span> <span class="ow">Mod</span> <span class="mi">7</span> <span class="o">-</span> <span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">KW</span> <span class="o">=</span> <span class="p">(</span><span class="n">myDate</span> <span class="o">-</span> <span class="n">t</span> <span class="o">-</span> <span class="mi">3</span> <span class="o">+</span> <span class="p">(</span><span class="n">Weekday</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">Mod</span> <span class="mi">7</span><span class="p">)</span> <span class="o">\</span> <span class="mi">7</span> <span class="o">+</span> <span class="mi">1</span> </span><span id="L-5"><a name="L-5"></a><span class="k">End</span> <span class="k">Function</span> </span></pre></div> </td></tr></table>
date, vbscript