<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dates : Astuces de programmation Le MEMO du Web Développeur</title>
	<atom:link href="https://memo-web.fr/tag/dates/feed/" rel="self" type="application/rss+xml" />
	<link>https://memo-web.fr</link>
	<description></description>
	<lastBuildDate>Wed, 15 Apr 2020 07:13:27 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>Opérations sur les dates: trouver la date précédente ou suivante d&#8217;une date donnée</title>
		<link>https://memo-web.fr/categorie-php-204/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-php-204</link>
					<comments>https://memo-web.fr/categorie-php-204/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Mon, 09 Sep 2013 07:40:32 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Dates]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=90</guid>

					<description><![CDATA[<p>Trouver la date précédente et la date suivante d&#8217;une date au format SQL</p>
The post <a href="https://memo-web.fr/categorie-php-204/">Opérations sur les dates: trouver la date précédente ou suivante d’une date donnée</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>Trouver la date précédente et la date suivante d&rsquo;une date au format SQL</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php
     // ou reçoit une date provenant d'une requête
     $date_provenant_d_une_table = "2013-05-01 00:00:00"; 
     $date = new DateTime($date_provenant_d_une_table);
     // si l'on s'intéresse au mois précédent
     $date->modify("-1 month"); 
     // On définit le format à afficher de la date
     $date = $date->format("Y-m-d"); 
     echo $date; // Affiche "2013-04-01"
     
     // ou reçoit une date provenant d'une requête
     $date_provenant_d_une_table = "2013-05-01 00:00:00"; 
     $date = ?new DateTime($date_provenant_d_une_table);
     // si l'on s'intéresse au jours suivants
     $date->modify("+5 day"); 
     // On définit le format à afficher de la date
     $date = $date->format("Y-m-d"); 
     echo $date; // Affiche "2013-04-06" 
?></pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-php-204/">Opérations sur les dates: trouver la date précédente ou suivante d’une date donnée</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-php-204/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Transformer une date format français en format SQL</title>
		<link>https://memo-web.fr/categorie-php-184/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-php-184</link>
					<comments>https://memo-web.fr/categorie-php-184/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Wed, 03 Apr 2013 13:30:30 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Dates]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=106</guid>

					<description><![CDATA[<p>La fonction PHP suivante transforme la date&#160;$date&#160;écrite au format français j/d/Y (03/04/2013) en format Mysql Y-m-d (2013-04-03)</p>
The post <a href="https://memo-web.fr/categorie-php-184/">Transformer une date format français en format SQL</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>La fonction PHP suivante transforme la date&nbsp;<em>$date</em>&nbsp;écrite au format français j/d/Y (03/04/2013) en format Mysql Y-m-d (2013-04-03)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">function FormaterDateFrEnSQL{ $date_sql=date('Y-m-d 00:00:00', strtotime(str_replace ('/', '-', $date))); }</pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-php-184/">Transformer une date format français en format SQL</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-php-184/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Convertir un format dateTime Français en format MySQL</title>
		<link>https://memo-web.fr/categorie-php-176/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-php-176</link>
					<comments>https://memo-web.fr/categorie-php-176/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Tue, 29 Jan 2013 14:36:08 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Dates]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=115</guid>

					<description><![CDATA[<p>Soit une date au format Français$date&#160;&#160; =&#8217;13/03/2013 10:50&#8242;; La fonction suivante&#160;DateFR2DateSQL($date) la convertit en format SQL soit : 2013-03-13 10:50</p>
The post <a href="https://memo-web.fr/categorie-php-176/">Convertir un format dateTime Français en format MySQL</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>Soit une date au format Français<br>$date&nbsp;&nbsp; =&rsquo;13/03/2013 10:50&prime;;</p>



<p>La fonction suivante&nbsp;<strong>DateFR2DateSQL</strong>($date) la convertit en format SQL soit :</p>



<p>2013-03-13 10:50</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">function DateFR2DateSQL ($date) {

  $day    = substr($date,0,2);
  $month  = substr($date,3,2);
  $year   = substr($date,6,4);
  $hour   = substr($date,12,2);
  $minute = substr($date,15,2);
  $second = substr($date,18,2);
  $timestamp= mktime($hour,$minute,$second,$month,$day,$year);
  return date('Y-m-d H:i:s',$timestamp);  
}

 </pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-php-176/">Convertir un format dateTime Français en format MySQL</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-php-176/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DatePicker de JQuery : Déployer le calendrier à l&#8217;ouverture de la page</title>
		<link>https://memo-web.fr/categorie-jquery-102/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-jquery-102</link>
					<comments>https://memo-web.fr/categorie-jquery-102/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Tue, 04 Dec 2012 08:14:18 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Astuce]]></category>
		<category><![CDATA[Dates]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=326</guid>

					<description><![CDATA[<p>Le plugin calendrier Datepicker&#160;de JQueryUI se déploie par défaut si l&#8217;on click sur le champs de date (en fait lorsque le champs prend le focus)&#160;?&#160;voir exemple ici&#160;sur le champs de la date de naissance. On peut parfois vouloir déployer le calendrier automatiquement dès l&#8217;ouverture de la page, pour ce faire il sufffit, grâce à JQuery [&#8230;]</p>
The post <a href="https://memo-web.fr/categorie-jquery-102/">DatePicker de JQuery : Déployer le calendrier à l’ouverture de la page</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p><a href="http://docs.jquery.com/UI/Datepicker">Le plugin calendrier Datepicker&nbsp;</a>de JQueryUI se déploie par défaut si l&rsquo;on click sur le champs de date (en fait lorsque le champs prend le focus)&nbsp;?&nbsp;<a href="http://memo-web.fr/user-connexion.php">voir exemple ici&nbsp;</a>sur le champs de la date de naissance.</p>



<p>On peut parfois vouloir déployer le calendrier automatiquement dès l&rsquo;ouverture de la page, pour ce faire il sufffit, grâce à JQuery de mettre le focus sur l&rsquo;input du champs de date au chargement de la page</p>



<p>Code HTML&nbsp;:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;input id="moncalendrier" type="datepicker"  name="moncalendrier" value="04/12/2012"/></pre>



<p>Code JQuery&nbsp;:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;script type="text/javascript">     
 $(document).ready( function () {
    $( "#moncalendrier").datepicker({ showOn: "both",                           
        buttonImage: "../img/b_calendar.png",
        buttonImageOnly: true,
        buttonText:'Cliquer pour choisir une date',
        onClose: function(dateText, inst) {  }, $options });

    $('#moncalendrier').focus();
       
});    
&lt;/script></pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-jquery-102/">DatePicker de JQuery : Déployer le calendrier à l’ouverture de la page</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-jquery-102/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Afficher une image différente selon la date de l&#8217;année en javascript</title>
		<link>https://memo-web.fr/categorie-jquery-138/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-jquery-138</link>
					<comments>https://memo-web.fr/categorie-jquery-138/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Wed, 08 Aug 2012 07:06:47 +0000</pubDate>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Astuce]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Images]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=316</guid>

					<description><![CDATA[<p>Ce script javascript permet d&#8217;afficher une image de background&#160;différente selon les saisons à l&#8217;élément d&#8217;identifiant id= »monimage » L&#8217;idée est d&#8217;analyser la date courante afin de déterminer la saison en utilisant l&#8217;objet&#160;new Date(année, mois, jour)</p>
The post <a href="https://memo-web.fr/categorie-jquery-138/">Afficher une image différente selon la date de l’année en javascript</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>Ce script javascript permet d&rsquo;afficher une image de background&nbsp;différente selon les saisons à l&rsquo;élément d&rsquo;identifiant id= »monimage »</p>



<p>L&rsquo;idée est d&rsquo;analyser la date courante afin de déterminer la saison en utilisant l&rsquo;objet&nbsp;<strong>new Date(année, mois, jour)</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;script>
  $(function() {
    var today = new Date();
    var ladate=Date.parse(today);
    var lannee = today.getFullYear();
    var dateprintemps  =Date.parse(new Date(lannee, 2, 21));
    var dateete        =Date.parse(new Date(lannee, 5, 21));
    var dateautomne    =Date.parse(new Date(lannee, 8, 21));
    var datehiver      =Date.parse(new Date(lannee, 11, 21));
    if(ladate>=dateprintemps &amp;&amp; ladate&lt;dateete){
      $("#monimage").css({backgroundImage: "url('img/Fond-Printemps.png')"}); }
    else if(ladate>=dateete &amp;&amp; ladate&lt;dateautomne){
      $("#monimage").css({backgroundImage: "url('img/Fond-Ete.png')"});  }
    else if(ladate>=dateautomne &amp;&amp; ladate&lt;datehiver){
      $("#monimage").css({backgroundImage: "url('img/Fond-Automne.png')"});  }
    else if(ladate>=datehiver || ladate&lt;dateprintemps){
      $("#monimage").css({backgroundImage: "url('img/Fond-Hiver.png')"});  }
});
&lt;/script></pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-jquery-138/">Afficher une image différente selon la date de l’année en javascript</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-jquery-138/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Problème à l&#8217;affichage de l&#8217;heure en PHP &#8211; 2h de moins</title>
		<link>https://memo-web.fr/categorie-php-124/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-php-124</link>
					<comments>https://memo-web.fr/categorie-php-124/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Mon, 02 Jul 2012 13:49:42 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[php.ini]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=139</guid>

					<description><![CDATA[<p>Si la fonction date de php vous affiche deux heures de moins (pour la France qui est en GMT+2, varie en fonction du fuseau horaire) Ouvrez dans WAMP le fichier php.ini (click sur icône de WAMP &#62; menu PHP &#62; php.ini), ouvrez php.ini avec un éditeur quelconque et modifiez la ligne tel que suit (au [&#8230;]</p>
The post <a href="https://memo-web.fr/categorie-php-124/">Problème à l’affichage de l’heure en PHP – 2h de moins</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>Si la fonction date de php vous affiche deux heures de moins (pour la France qui est en GMT+2, varie en fonction du fuseau horaire)</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">echo 'la date : '.date("Y-m-d H:i:s");</pre>



<p>Ouvrez dans WAMP le fichier php.ini (click sur icône de WAMP &gt; menu PHP &gt; php.ini), ouvrez php.ini avec un éditeur quelconque et modifiez la ligne tel que suit (au besoin, décommentez la en enlevant le point virgule qui la précède) :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">date.timezone = "Europe/Brussels"</pre>



<p>Et n&rsquo;oubliez pas de&nbsp;redémarrer les services&nbsp;WAMP après toute modification du fichier php.ini</p>



<p>(Si vous n&rsquo;êtes pas en France,&nbsp;<a href="http://us3.php.net/manual/en/timezones.php" target="_blank" rel="noreferrer noopener">trouvez l&rsquo;identifiant de votre fuseau horaire</a>)</p>



<p>PHP utilise en effet l&rsquo;heure du serveur, et non l&rsquo;heure de la machine.</p>



<p>Si l&rsquo;on n&rsquo;a pas accès au php.ini, on peut utiliser la fonction php&nbsp;<a href="http://fr2.php.net/manual/fr/function.date-default-timezone-set.php" target="_blank" rel="noreferrer noopener">date_default_timezone_set</a>&nbsp;qui définit le décalage horaire à appliquer par défaut de toutes les fonctions de date et heure en PHP<br></p>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-php-124/">Problème à l’affichage de l’heure en PHP – 2h de moins</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-php-124/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Opérations sur les dates en PHP</title>
		<link>https://memo-web.fr/categorie-php-109/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorie-php-109</link>
					<comments>https://memo-web.fr/categorie-php-109/#respond</comments>
		
		<dc:creator><![CDATA[t@ra]]></dc:creator>
		<pubDate>Tue, 13 Mar 2012 14:50:49 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Dates]]></category>
		<guid isPermaLink="false">http://memo-web.fr/?p=141</guid>

					<description><![CDATA[<p>Modifier en PHP l&#8217;heure ou le mois ou le jour d&#8217;une date au format SQL. Le code suivant rajoute une année, deux mois et un jour à la date $madate.</p>
The post <a href="https://memo-web.fr/categorie-php-109/">Opérations sur les dates en PHP</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></description>
										<content:encoded><![CDATA[<p>Modifier en PHP l&rsquo;heure ou le mois ou le jour d&rsquo;une date au format SQL.</p>



<p>Le code suivant rajoute une année, deux mois et un jour à la date $madate.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php
  $madate= '2012-03-13 12:00:00';
  list($annee,$mois,$jour,$h,$m,$s)=sscanf($madate,"%d-%d-%d %d:%d:%d");
  echo "Date initiale: ".$jour."/".$mois."/".$annee." ".$h.":".$m.":".$s."&lt;br />";
  $mois+=2;
  $annee++;
  $jour++;
  $timestamp=mktime($h,$m,$s,$mois,$jour,$annee);
  $date_finale=date('d/m/Y H:i:s',$timestamp);
  echo "Une année, deux mois et un jour plus tard : ".$date_finale;
?></pre>
<div style="margin-top: 0px; margin-bottom: 0px;" class="sharethis-inline-share-buttons" ></div>The post <a href="https://memo-web.fr/categorie-php-109/">Opérations sur les dates en PHP</a> first appeared on <a href="https://memo-web.fr">Le MEMO du Web Développeur</a>.]]></content:encoded>
					
					<wfw:commentRss>https://memo-web.fr/categorie-php-109/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
