Skip to content

Instantly share code, notes, and snippets.

@cladjidane
Created November 7, 2022 16:12
Show Gist options
  • Save cladjidane/4679c445fb4992ad883f1659cf58fdce to your computer and use it in GitHub Desktop.
Save cladjidane/4679c445fb4992ad883f1659cf58fdce to your computer and use it in GitHub Desktop.
<?php
setlocale(LC_ALL, 'fr_FR') or die('Locale not installed');
//setlocale(LC_ALL, 'en_EN') or die('Locale not installed');
?>
<h2>Q1</h2>
<?php echo strftime('%A %d %B %Y'); ?>
<hr />
<?php echo strftime('%d/%m/%Y %I:%M:%S'); ?>
<hr />
<?php echo time(); ?>
<h2>Q2</h2>
<?php
$date1=date_create("1973-12-13");
$date2=date_create("now");
$diff=date_diff($date1,$date2);
?>
Nombre total de jours : <?php echo $diff->format("%R%a jours"); ?>
<hr />
Nombre total de secondes : <?php echo $date2->getTimestamp() - $date1->getTimestamp(); ?>
<hr />
Nombre total d'années : <?php echo $diff->format("%Y"); ?> -
Nombre total de mois : <?php echo $diff->format("%m"); ?> -
Nombre total de jours : <?php echo $diff->format("%a"); ?>
<h2>Q3</h2>
<?php
$now = new DateTime("now");
$start_date = $now;
?>
Date du jour : <?php echo $now->format('d/m/Y H:i:s'); ?>
<hr />
<?php
$interval = new DateInterval("P29DT12H44M3S");
$end_date = $now->add($interval);
?>
Date dans 1 pleine lune : <?php echo $now->format('d/m/Y H:i:s'); ?>
<hr />
<?php
$s = $end_date->getTimestamp() - time();
$interval2 = new DateInterval("PT".($s*100)."S");
$now->add($interval2);
?>
Date dans 100 pleine lune : <?php echo $now->format('d/m/Y H:i:s'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment