Answers for "date range php"

PHP
5

php date plus days

<?php 
// PHP program to add days to $Date 
  
// Declare a date 
$date = "2019-05-10"; 
  
// Add days to date and display it 
echo date('Y-m-d', strtotime($date. ' + 10 days')); 
  
?>
Posted by: Guest on June-04-2020
1

range in php

<?php
  // range($start, $end [,$steps])
  $numbers = range(0, 5);
  print_r($numbers);
  // Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
	
  $numbers2 = range(0, 5, 2);
  print_r($numbers2);
  //Array ( [0] => 0 [1] => 2 [2] => 4 )
  
  
  ?>
Posted by: Guest on July-22-2021
0

php range

function range($start, $end, int|float $step = 1) array
-------------------------------------------------------
Create an array containing a range of elements.
  
Parameters:
mixed--$start--First value of the sequence.
mixed--$end--The sequence is ended upon reaching the end value.
float|int--$step--[optional]--If a step value is given, it will be used as the increment between elements in the sequence. 
Step should be given as a positive number. If not specified, step will default to 1.
  
Returns: an array of elements from start to end, inclusive.
  
Example :
=========
  foreach ( range( 0, 60, 11 ) as $numbers ) {
	if ( $numbers > 0 ) {
		echo $numbers;
		echo PHP_EOL;
	}
}
Posted by: Guest on September-11-2021

Browse Popular Code Answers by Language