snipt

Ctrl+h for KB shortcuts

PHP

Localize dates in Wordpress

1
2
3
<?php 
echo date_i18n(get_option('date_format') ,strtotime("11/15-1976"));
?>
https://snipt.net/embed/e7b487b882a71fd1dbf55f6c235b3df1/
/raw/e7b487b882a71fd1dbf55f6c235b3df1/
e7b487b882a71fd1dbf55f6c235b3df1
php
PHP
3
2019-06-06T05:20:03
True
False
False
Dec 11, 2013 at 07:25 AM
/api/public/snipt/99832/
localize-dates-in-wordpress
<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="k">echo</span> <span class="nx">date_i18n</span><span class="p">(</span><span class="nx">get_option</span><span class="p">(</span><span class="s1">&#39;date_format&#39;</span><span class="p">)</span> <span class="p">,</span><span class="nb">strtotime</span><span class="p">(</span><span class="s2">&quot;11/15-1976&quot;</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, localize, wordpress, wp

Java

Date to XMLGregorianCalendar

1
2
3
4
GregorianCalendar gregorianCalendar = new GregorianCalendar();
Date date = new Date();
gregorianCalendar.setTime(date);
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
https://snipt.net/embed/31c7f51c792da0ab15b0e65d68c2b262/
/raw/31c7f51c792da0ab15b0e65d68c2b262/
31c7f51c792da0ab15b0e65d68c2b262
java
Java
4
2019-06-09T03:58:35
True
False
False
Nov 15, 2013 at 12:50 AM
/api/public/snipt/94290/
date-to-xmlgregoriancalendar
<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="n">GregorianCalendar</span> <span class="n">gregorianCalendar</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GregorianCalendar</span><span class="o">();</span> </span><span id="L-2"><a name="L-2"></a><span class="n">Date</span> <span class="n">date</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Date</span><span class="o">();</span> </span><span id="L-3"><a name="L-3"></a><span class="n">gregorianCalendar</span><span class="o">.</span><span class="na">setTime</span><span class="o">(</span><span class="n">date</span><span class="o">);</span> </span><span id="L-4"><a name="L-4"></a><span class="n">XMLGregorianCalendar</span> <span class="n">xmlGregorianCalendar</span> <span class="o">=</span> <span class="n">DatatypeFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">().</span><span class="na">newXMLGregorianCalendar</span><span class="o">(</span><span class="n">gregorianCalendar</span><span class="o">);</span> </span></pre></div> </td></tr></table>
"gregorian calendar", "xml gregorian calendar", date, java

Java

Get first day of week

1
2
3
4
5
Calendar calendar = Calendar.getInstance(Locale.US);  
System.out.println("First Day Of Week: " + calendar.getFirstDayOfWeek());  
  
calendar = Calendar.getInstance(Locale.FRANCE);  
System.out.println("First Day Of Week: " + calendar.getFirstDayOfWeek());  
https://snipt.net/embed/2d9bda6c9989df4b83c27bdaf5c0e716/
/raw/2d9bda6c9989df4b83c27bdaf5c0e716/
2d9bda6c9989df4b83c27bdaf5c0e716
java
Java
5
2019-06-17T10:26:20
True
False
False
/api/public/snipt/88073/
get-first-day-of-week
<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="n">Calendar</span> <span class="n">calendar</span> <span class="o">=</span> <span class="n">Calendar</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="n">Locale</span><span class="o">.</span><span class="na">US</span><span class="o">);</span> </span><span id="L-2"><a name="L-2"></a><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&quot;First Day Of Week: &quot;</span> <span class="o">+</span> <span class="n">calendar</span><span class="o">.</span><span class="na">getFirstDayOfWeek</span><span class="o">());</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="n">calendar</span> <span class="o">=</span> <span class="n">Calendar</span><span class="o">.</span><span class="na">getInstance</span><span class="o">(</span><span class="n">Locale</span><span class="o">.</span><span class="na">FRANCE</span><span class="o">);</span> </span><span id="L-5"><a name="L-5"></a><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&quot;First Day Of Week: &quot;</span> <span class="o">+</span> <span class="n">calendar</span><span class="o">.</span><span class="na">getFirstDayOfWeek</span><span class="o">());</span> </span></pre></div> </td></tr></table>
date, java

PHP

Codelgniter Manual Where use OR

1
2
3
4
<?php

$this->db->where( ' ( db_data.date_exp > '. strtotime( 'now' ) . 
                 ' OR db_data.date_exp = 0 ) ', false , false );
https://snipt.net/embed/86b67c234e881d9b0dd37ad11eeb0901/
/raw/86b67c234e881d9b0dd37ad11eeb0901/
86b67c234e881d9b0dd37ad11eeb0901
php
PHP
5
2016-12-27T15:04:22
True
False
True
Sep 09, 2013 at 04:31 AM
/api/public/snipt/79783/
codelgniter-manual-where-use-or
<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">$this</span><span class="o">-&gt;</span><span class="na">db</span><span class="o">-&gt;</span><span class="na">where</span><span class="p">(</span> <span class="s1">&#39; ( db_data.date_exp &gt; &#39;</span><span class="o">.</span> <span class="nb">strtotime</span><span class="p">(</span> <span class="s1">&#39;now&#39;</span> <span class="p">)</span> <span class="o">.</span> </span><span id="L-4"><a name="L-4"></a> <span class="s1">&#39; OR db_data.date_exp = 0 ) &#39;</span><span class="p">,</span> <span class="k">false</span> <span class="p">,</span> <span class="k">false</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
codeigniter, date