snipt

Ctrl+h for KB shortcuts

VB.net

VB – Convert PoliceTime to DateTime

1
2
3
4
5
6
7
8
Private Function ConvertPoliceTime2DateTime(arg As String) As DateTime
    Dim rval As UInt16
    
    ConvertPoliceTime2DateTime = Nothing
    If UInt16.TryParse(arg, rval) Then
    	ConvertPoliceTime2DateTime = DateTime.Parse((rval \ 100).ToString() & ":" & (rval Mod 100).ToString())
    End If
End Function
https://snipt.net/embed/4ace7fa5670a0eaee01c482a8c599da1/
/raw/4ace7fa5670a0eaee01c482a8c599da1/
4ace7fa5670a0eaee01c482a8c599da1
vb.net
VB.net
8
2019-06-10T12:01:50
True
False
False
Oct 28, 2012 at 06:07 PM
/api/public/snipt/49221/
vb-convert-policetime-to-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> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</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">Private</span> <span class="k">Function</span> <span class="nf">ConvertPoliceTime2DateTime</span><span class="p">(</span><span class="n">arg</span> <span class="ow">As</span> <span class="kt">String</span><span class="p">)</span> <span class="ow">As</span> <span class="n">DateTime</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">Dim</span> <span class="n">rval</span> <span class="ow">As</span> <span class="n">UInt16</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a> <span class="n">ConvertPoliceTime2DateTime</span> <span class="o">=</span> <span class="k">Nothing</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">If</span> <span class="n">UInt16</span><span class="p">.</span><span class="n">TryParse</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">rval</span><span class="p">)</span> <span class="k">Then</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">ConvertPoliceTime2DateTime</span> <span class="o">=</span> <span class="n">DateTime</span><span class="p">.</span><span class="n">Parse</span><span class="p">((</span><span class="n">rval</span> <span class="o">\</span> <span class="mi">100</span><span class="p">).</span><span class="n">ToString</span><span class="p">()</span> <span class="o">&amp;</span> <span class="s">&quot;:&quot;</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">rval</span> <span class="ow">Mod</span> <span class="mi">100</span><span class="p">).</span><span class="n">ToString</span><span class="p">())</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">End</span> <span class="k">If</span> </span><span id="L-8"><a name="L-8"></a><span class="k">End</span> <span class="k">Function</span> </span></pre></div> </td></tr></table>
date, jsd, vb

VB.net

VB – Check DateTime

1
2
3
4
5
6
7
If Minute(myDate) + Hour(myDate) * 60 > Minute(Now) + Hour(Now) * 60 Then
	Msgbox("Die Zeit liegt in der Zukunft")
End If

If myDate.Date > Today.Date Then
	Msgbox("Das Datum liegt in der Zukunft")
End If
https://snipt.net/embed/e54674d3095227234ae26faeda0e92d8/
/raw/e54674d3095227234ae26faeda0e92d8/
e54674d3095227234ae26faeda0e92d8
vb.net
VB.net
7
2019-06-03T01:38:32
True
False
False
Oct 28, 2012 at 06:08 PM
/api/public/snipt/49215/
vb-check-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> <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="k">If</span> <span class="n">Minute</span><span class="p">(</span><span class="n">myDate</span><span class="p">)</span> <span class="o">+</span> <span class="n">Hour</span><span class="p">(</span><span class="n">myDate</span><span class="p">)</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">&gt;</span> <span class="n">Minute</span><span class="p">(</span><span class="n">Now</span><span class="p">)</span> <span class="o">+</span> <span class="n">Hour</span><span class="p">(</span><span class="n">Now</span><span class="p">)</span> <span class="o">*</span> <span class="mi">60</span> <span class="k">Then</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">Msgbox</span><span class="p">(</span><span class="s">&quot;Die Zeit liegt in der Zukunft&quot;</span><span class="p">)</span> </span><span id="L-3"><a name="L-3"></a><span class="k">End</span> <span class="k">If</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="k">If</span> <span class="n">myDate</span><span class="p">.</span><span class="n">Date</span> <span class="o">&gt;</span> <span class="n">Today</span><span class="p">.</span><span class="n">Date</span> <span class="k">Then</span> </span><span id="L-6"><a name="L-6"></a> <span class="n">Msgbox</span><span class="p">(</span><span class="s">&quot;Das Datum liegt in der Zukunft&quot;</span><span class="p">)</span> </span><span id="L-7"><a name="L-7"></a><span class="k">End</span> <span class="k">If</span> </span></pre></div> </td></tr></table>
date, jsd, vb

PHP

Add time to a date

1
2
3
<?php

$new_date	= date('Y-m-d', strtotime("+30 days"));
https://snipt.net/embed/a13bd0c49d0ecf8829181c1311884728/
/raw/a13bd0c49d0ecf8829181c1311884728/
a13bd0c49d0ecf8829181c1311884728
php
PHP
3
2019-05-31T04:41:51
True
False
False
Oct 15, 2012 at 11:02 AM
/api/public/snipt/48592/
add-time-to-a-date
<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><span id="L-3"><a name="L-3"></a><span class="nv">$new_date</span> <span class="o">=</span> <span class="nb">date</span><span class="p">(</span><span class="s1">&#39;Y-m-d&#39;</span><span class="p">,</span> <span class="nb">strtotime</span><span class="p">(</span><span class="s2">&quot;+30 days&quot;</span><span class="p">));</span> </span></pre></div> </td></tr></table>
date, php

JavaScript

Get Timestamp and Date from Mongo ID

var timestamp = _id.toString().substring( 0, 8 );
var date = new Date( parseInt( timestamp, 16 ) * 1000 );
https://snipt.net/embed/dc5fb59a142040acdfe7da784540b72f/
/raw/dc5fb59a142040acdfe7da784540b72f/
dc5fb59a142040acdfe7da784540b72f
js
JavaScript
2
2019-06-16T15:22:45
True
False
False
Oct 02, 2012 at 11:40 AM
/api/public/snipt/47925/
get-timestamp-and-date-from-mongo-id
<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><span class="kd">var</span> <span class="nx">timestamp</span> <span class="o">=</span> <span class="nx">_id</span><span class="p">.</span><span class="nx">toString</span><span class="p">().</span><span class="nx">substring</span><span class="p">(</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">8</span> <span class="p">);</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">var</span> <span class="nx">date</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">(</span> <span class="nb">parseInt</span><span class="p">(</span> <span class="nx">timestamp</span><span class="p">,</span> <span class="mi">16</span> <span class="p">)</span> <span class="o">*</span> <span class="mi">1000</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
date, id, mongo, timestamp

CSS

Symfony 1.x : Style auto on sfWidgetFormDate rendering

1
2
3
4
5
select[name$="[day]"],
select[name$="[month]"],
select[name$="[year]"] {
    width: 70px;
}
https://snipt.net/embed/adc6c153366a65612fb199a73d545a95/
/raw/adc6c153366a65612fb199a73d545a95/
adc6c153366a65612fb199a73d545a95
css
CSS
5
2016-12-29T19:11:45
True
False
True
Sep 16, 2012 at 09:49 AM
/api/public/snipt/47249/
symfony-1x-style-auto-on-sfwidgetformdate-rendering
<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="nt">select</span><span class="o">[</span><span class="nt">name</span><span class="o">$=</span><span class="s2">&quot;[day]&quot;</span><span class="o">],</span> </span><span id="L-2"><a name="L-2"></a><span class="nt">select</span><span class="o">[</span><span class="nt">name</span><span class="o">$=</span><span class="s2">&quot;[month]&quot;</span><span class="o">],</span> </span><span id="L-3"><a name="L-3"></a><span class="nt">select</span><span class="o">[</span><span class="nt">name</span><span class="o">$=</span><span class="s2">&quot;[year]&quot;</span><span class="o">]</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">width</span><span class="o">:</span> <span class="m">70px</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
Symfony, css, date