File "timestamp.php"

Full Path: /home/analogde/www/Design/fileman/Fusion/Table/timestamp.php
File size: 2.08 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->format('%a total days')."\n";
	echo " ----> " .$interval->format('%m month, %d days');

	echo "<br>";
	echo "<br>";
	
	// 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 ;
	
	$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);
}

?>