Print year range wise in php

php date
strtotime
php datetime
php date_format
php datetime::format
php date from string
php time
php get month from date
<?php
    for($i=1990;$i<=(date('Y')-1);$i++)
    {
        for($j=1991;$j<=date('Y');$j++)
        {

        }
        echo $i.'-'.$j."<br/>";
    }
?>

I want to print year in range format like 1990-1991 from 1990-1991 to 2018-2019. In my code when I print range it shows me 1990-2020,1991-2020,1992-2020 like that. So, How can I print year in proper range like 1990-1991,1991-1992,1992-1993? Please help me.

Thank You

$start =  1990;
$end = date('Y');

for( $i=$start; $i < $end; $i++ ){
    printf('%d - %d<br />',$i,$i+1);
}

will output:

1990 - 1991
1991 - 1992
1992 - 1993
1993 - 1994
1994 - 1995
1995 - 1996
1996 - 1997
1997 - 1998
1998 - 1999
1999 - 2000
2000 - 2001
2001 - 2002
2002 - 2003
2003 - 2004
2004 - 2005
2005 - 2006
2006 - 2007
2007 - 2008
2008 - 2009
2009 - 2010
2010 - 2011
2011 - 2012
2012 - 2013
2013 - 2014
2014 - 2015
2015 - 2016
2016 - 2017
2017 - 2018
2018 - 2019

date - Manual, 5.1.0, The valid range of a timestamp is typically from Fri, 13 Dec 1901 echo date("oW", strtotime("2011-01-01")); // gives 201052 (Year is different than 0); # If the start day is Saturday or Sunday, add zero, otherewise add six minus the� PHP Version: 4+ PHP Changelog: The step parameter was added in PHP 5.0. In PHP versions 4.1.0 through 4.3.2, this function sees numeric strings as strings and not integers. The numeric strings will be used for character sequences, e.g., "5252" is treated as "5". Support for character sequences and decrementing arrays was added in PHP 4.1.0.

I think you should put your echo inside the 2nd loop. and assign the first variable to have it's value. This should be like this.

    <?php
    for($i=1990;$i<=(date('Y')-1);$i++)
    {
        for($j=1991;$j<=date('Y');$j++)
        {
           echo $i.'-'.$j."<br/>";

            $i = $j;
        }

    }
?>

Hope this helps!

strftime - Manual, %W, A numeric representation of the week of the year, starting with the first Monday as the echo strftime(" in Finnish is %A,"); echo strftime(" in French % A and"); $week_numbers = range(strftime('%U', mktime(0,0,0,$month,1,$year)) +� PHP Version: 4+ Changelog: PHP 5.1.0: Added E_STRICT and E_NOTICE time zone errors. Valid range of timestamp is now from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. Before version 5.1.0 timestamp was limited from 01-01-1970 to 19-01-2038 on some systems (e.g. Windows).

<?php
$start = 1999;
$end   = 2006;

for($i=$start; $i<$end; $i++)
    $ranges[] = $i . '-' . ($i+1);

print implode(', ', $ranges);

Output:

1999-2000, 2000-2001, 2001-2002, 2002-2003, 2003-2004, 2004-2005, 2005-2006

DatePeriod - Manual, 7 years ago 8 years ago 3 years ago echo $dt->format( "l Y-m-d H:i:s\n" ); ? > Modify the $subscription_start_date date value to required date range, @ErikvanBrakel just out of interest the current year in thailand is 2556. not sure if PHP locale takes this into account but in a perfect world it should :) – Dirk Hartzer Waldeck Feb 6 '13 at 12:41

Date/Time Functions - Manual, 8 years ago. I needed a way to display an announcement on a shopping site, that would warn users that orders placed between a certain date range, would not� We have to print natural numbers columns wise with decreasing size, depending upon given number of lines as described in the examples below – Examples : Input : 5 Output : 1 2 6 3 7 10 4 8 11 13 5 9 12 14 15 Input : 3 Output : 1 2 4 3 5 6

Selecting records between two date range query, Query for Getting records between two years, month or date ranges from a mysql table. We may not get data always in this format so here is the PHP code to convert to this hi i need the query for display the dates between the two dates, and my condition is only I want to select from-date to-date wise data show in form You already know that Unix time is the number of seconds since January 1, 1970 in UTC, so that gives you a constant time zone to work with, and hopefully you’ve noticed that many of PHP’s date

Return all dates between two dates in an array in PHP , use date interval class which stores fixed amount of time (in years, months, Function to get all the dates in given range Display the dates in array format. Python Basic: Exercise-12 with Solution. Write a Python program to print the calendar of a given month and year. Note: Use 'calendar' module. Python calendar.month(theyear, themonth, w=0, l=0):

Comments
  • for($i=1990;$i<=(date('Y')-1);$i++) { echo $i.'-'.($i+1) . "<br/>"; } ?