File "timestamp.php"

Full Path: /home/analogde/www/Design/fileman/Fusion/Tableau/timestamp.php
File size: 3.35 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	date_default_timezone_set('Europe/Paris');


	$temps_debut = "2024-01-11";
	$temps_fin = "2024-01-25";

	$temps_debut = "11-01-2024";
	$temps_fin = "25-01-2024";
	
	f1($temps_debut, $temps_fin);
	
function f1($temps_debut, $temps_fin)
{


	$start_date = new DateTime($temps_debut);
	$end_date = new DateTime($temps_fin);
 
	echo "Start " .$temps_debut . " - " .$start_date->getTimestamp();
	echo "<BR>";
	echo "Stop " .$temps_fin . " - " .$end_date->getTimestamp();
	echo "<BR>";
	
	
	$timestamp_start = $start_date->getTimestamp();
	$timestamp_stop = $end_date->getTimestamp();
	
	
	/* OK
	$january = new DateTime('2010-01-01');
	$february = new DateTime('2010-02-01');
	$interval = $february->diff($january);
	$interval = $end_date->diff($start_date);


	// %a will output the total number of days.
	echo $interval->format('%a total days')."\n";

	// While %d will only output the number of days not already covered by the
	// month.
	echo $interval->format('%m month, %d days');
	*/
	
	$interval = $end_date->diff($start_date);
	
	echo $interval->d.' Days<br>'; 
	
//	echo date('D', strtotime($date));
///echo date('l', strtotime($date));
	
	// OK
	$datetime = DateTime::createFromFormat('d/m/Y', '19/02/2024');
    echo $datetime->format('l');
	echo "<br>";
	
	// OK
	$paymentDate = '2024/02/23';
    echo " **** " .$day = date('l', strtotime($paymentDate));
	echo "<br>";
	
	$date = "2024-02-19";
    $newDate = date('l', strtotime($date));
    echo " //// " .$newDate;
	echo "<br>";
	
	// OK
	$date = date_create("2024-02-19");
    echo "  ----- " .date_format($date,"l");
	echo "<br>";
	
	// numéro de la semaine et année
	$date = strtotime('2024-02-19');
	echo date("W Y", $date);  
	echo "<br>";
	
	// jour de la semaine  Lun 1 à Dim 
	$debut_date = "2024-02-19";
	$blabla_date = new DateTime($debut_date);
	$timestamp_debut = $blabla_date->getTimestamp();
	echo " $$$$$$$$ " .date('N', $timestamp_debut);
	echo "<br>";
	
	
	// http://www.java2s.com/Tutorials/PHP/Data_Types/Date/Calculate_the_interval_between_two_dates_then_format_the_interval_in_PHP.htm
	
	// https://codeshack.io/event-calendar-php/
	
	// https://pluginus.net/shop/get-it-for-free/simple-free-open-source-ajax-php-calendar-script/
	
	//$day_number = date('N', $date);
	
	//echo " ----> " .$interval->format('%a total days')."\n";
	//echo " ----> " .$interval->format('%m month, %d days');

	
	
	// Finding the number of days between two dates
	
	$nombreSecondParJour = 3600 * 24; 
	
	//$date = new DateTime();
	//$date->setTimestamp($start_date);

	//echo $date->format('Y-m-d');
	
	$timestamp_start = $start_date->getTimestamp();
	
	$timestamp = $timestamp_start ;
	
	echo "<br>";
	echo "<br>";
	echo "<br>";
	
	$pipo = array();
	
	for ($x = 1; $x <= 10; $x++) 
	{
		$timestamp = $timestamp + $nombreSecondParJour;
		$dateTime = date('d-m-Y ', $timestamp );
		
		//echo gettype($dateTime);
		//echo "<br>";
		
		$item = (string)$x;
		//echo gettype($item);
		//echo "<br>";
		
		echo $item ." " .$dateTime;
		echo "<br>";
		
		$pipo[] = $dateTime;
		
		//$s = $dateTime + " titi";
		//echo $s;
		//echo "<br>";
		
		
		
		//echo $item + " 64644 ";
		
		//$result = $dateTime->format('Y-m-d H:i:s');
		
		//echo $item + $dateTime;
		
	}

	print_r($pipo);
	
	echo count($pipo);
}

?>