Answers for "php date range"

PHP
46

date php

$today = date("F j, Y, g:i a");                   // March 10, 2001, 5:16 pm
$today = date("m.d.y");                           // 03.10.01
$today = date("j, n, Y");                         // 10, 3, 2001
$today = date("Ymd");                             // 20010310
$today = date('h-i-s, j-m-y, it is w Day');       // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');     // It is the 10th day (10ème jour du mois).
$today = date("D M j G:i:s T Y");                 // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \e\s\t\ \l\e\ \m\o\i\s'); // 17:03:18 m est le mois
$today = date("H:i:s");                           // 17:16:18
$today = date("Y-m-d H:i:s");                     // 2001-03-10 17:16:18 (le format DATETIME de MySQL)
Posted by: Guest on April-07-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
2

date in php

FYI: there's a list of constants with predefined formats on the DateTime object, for example instead of outputting ISO 8601 dates with:

<?php
echo date('c');
?>

or

<?php
echo date('Y-m-d\TH:i:sO');
?>

You can use

<?php
echo date(DateTime::ISO8601);
?>

instead, which is much easier to read.
Posted by: Guest on October-19-2020
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