How to get dates between two dates

List of Dates between my From and Two

<?php $scheduleStartDate = 2015-06-20; $scheduleEndDate = 2015-06-25; $Date = getDatesFromRange($scheduleStartDate,$scheduleEndDate); $Date = substr($Date, 0, -1); function getDatesFromRange($start, $end){ $dates = array($start); $Value = ''; while(end($dates) < $end) { $dates[] = date('Y-m-d', strtotime(end($dates).' +1 day')); $Value .= '"'.date('j-n-Y', strtotime(end($dates).' +1 day')).'",'; } return $Value; } ?>

I'm passing it inside the script that I have , $Date is the one I got from above php file

<script> $( window ).load(function() { var availableDates = [<?php echo $Date?>]; function available(date) { dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear(); if ($.inArray(dmy, availableDates) != -1) { return [true, "","Available"]; } else { return [false,"","unAvailable"]; } } $('#date').datepicker({ beforeShowDay: available, currentText: "Now", dateFormat: 'yy-mm-dd', inline: true, altField: '#datepicker_value', onSelect: function(){ getData(); } }); }); </script>

Finally I'm enabling the dates in date picker But its enabling 2days late at stat and 1 day extra at the end
Say if I have dates from 20th to 25th it will enable dates from 22nd to 26th
Any help may greatly Appriciated.

-------------Problems Reply------------

Try this PHP code:

$scheduleStartDate = '2015-06-20';
$scheduleEndDate = '2015-06-25';
$Date = getDatesFromRange($scheduleStartDate, $scheduleEndDate);
$Date = substr($Date, 0, -1);
function getDatesFromRange($start, $end){
$startDate = new DateTime($start);
$endDate = new DateTime($end);
$endDate->modify('+1 day');
$daterange = new DatePeriod($startDate, new DateInterval('P1D'), $endDate);
$result = '';

foreach($daterange as $date){
$result .= '"'.$date->format("j-n-Y").'",';
return $result;

Category:php Views:5 Time:2018-12-30
Tags: php date

Related post

  • How to get difference between two dates in Year/Month/Week/Day? 2009-07-05

    How to get difference between two dates in Year/Month/Week/Day in an efficient way? eg. difference between two dates is 1 Year, 2 Months, 3 Weeks, 4 Days. Difference represents count of year(s), month(s), week(s) and day(s) between two dates. -------

  • How to get weekends between two dates? 2011-06-01

    Possible Duplicate: Calculate the number of weekdays between two dates in C# Is there a method to know how much saturdays and sundays there are between two dates? for example: 13/01/2011 to 28/02/2011 result will be: 3 saturdays and 3 sundays can som

  • How to get weeks between two dates 2012-03-23

    How do I get a reliable date diff in weeks? So far I've got <?php $a = new DateTime('2010-09-01'); $b = new DateTime(); $c = $a->diff($b); Now I get a DateInterval with years, months and so on, but as far as I know a year does not have exactly

  • How to get list of dates between two dates in mysql select query 2012-02-15

    This question already has an answer here: Get a list of dates between two dates 16 answers I want list of dates lies between two dates by select query. For example: If i give '2012-02-10' and '2012-02-15' I need the result. date ---------- 2012-02-10

  • How can I get all data between two dates from sqlite database? 2012-03-01

    In my sqlite database there is a "Date" field, & its data type is varchar, I want to get all data between two dates - how would I do this from a sqlite database? --------------Solutions------------- Try this NSString * sql = [[NSString alloc] ini

  • Get a list of dates between two dates using a function 2009-09-04

    FYI: My question is duplicate of this MySQL question, but intended for SQL Server Is there a function to write a query that will return a list of days between two dates? For example, lets say there is a function called ExplodeDates: SELECT ExplodeDat

  • How to find all dates between two dates in Zend Framework Query 2012-02-15

    I need to find all dates between two dates; that is start date and end date. Here is my query but it is not doing what I need it to do. In my table I have column name date_created which is in format like this 2011-06-09 06:41:10. I want to remove thi

  • XSLT 1.0: Get the list of dates between two dates using XSLT 2012-04-09

    I need to get the list of dates between two dates - for e.g. I have start date 03302012 and enddate 05302012 and I need the output like 03302012 03312012 04012012 04022012 ... 05282012 05292012 05302012 Feel free to use your date format - I will make

  • Xcode - How to find the middle date between two dates 2011-12-11

    I would like to find the middle date between two dates, in objective c. --------------Solutions------------- Look at NSDateComponents and dateByAddingComponents:toDate:options:, this is what I use and it works pretty good. Make sure to watch out for

  • Mysql: Select all data between two dates 2009-07-03

    I have a mysql table with data connected to dates. Each row has data and a date, like this: 2009-06-25 75 2009-07-01 100 2009-07-02 120 I have a mysql query that select all data between two dates. This is the query: SELECT data FROM tbl WHERE date BE

  • PHP : How to get milisecond between two dateTime obj? 2010-10-26

    PHP : How to get milisecond between two dateTime obj? $date = new DateTime(); $date2 = new DateTime("1990-08-07 08:44"); I try to follow the comment below but I got an error $stime = new DateTime($startTime->format("d-m-Y H:i:s")); $etime = new Da

  • SQL query to retrieve data between two dates 2014-01-15

    I've written following code: Dim date1 As Date Dim date2 As Date date1 = Convert.ToDateTime(DatePickerFromDate.Text) date2 = Convert.ToDateTime(DatePickerToDate.Text) Dim cnd As New OleDbCommand("SELECT * FROM Sales WHERE Invoice_Date BETWEEN " + dat

  • SQL query to select dates between two dates 2011-02-26

    I have a start_date and end_date. I want to get the list of dates in between these two dates. Can anyone help me pointing the mistake in my query. select Date,TotalAllowance from Calculation where EmployeeId=1 and Date between 2011/02/25 and 2011/02/

  • sqlite query for retrieving data between two dates saved as strings 2011-11-15

    NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO ADDEXPENSE(date, description, category, amount) VALUES (\"%@\", \"%@\", \"%@\",\"%@\")", fieldOne.text, fieldTwo.text,fieldThree.text , fieldFour.text]; i have taken a date picker for the

  • data between two dates in texbox:error in code 2011-04-26

    date textbox to textbox when in write date in text box the corrs data between two dates come in data grid *my code is:* private void btnSubmit_Click(object sender, EventArgs e) { SqlConnection cs = new SqlConnection("Data Source=IRIS-CSG-174;Initial

  • how to get a list of dates between two dates in java 2010-04-22

    I want a list of dates between start date and end date. The result should be a list of all dates including the start and end date. --------------Solutions------------- I suggest to use Joda-Time for that List<LocalDate> dates = new ArrayList

  • Get a list of dates between two dates 2009-02-04

    Using standard mysql functions is there a way to write a query that will return a list of days between two dates. eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values: 2009-01-01 2009-01-02 2009-01-03 2009-01-04 2009-

  • how to calculate difference between two dates using java 2009-10-12

    I'm using Java's class in Scala and want to compare a date object and the current time. I know I can calculate the delta by using getTime(): (new java.util.Date()).getTime() - oldDate.getTime() However, this just leaves me with a Long

  • Get data between two date on MySQL 2010-04-26

    How can I get the values between two dates. I want to get the values between 2010-01-02 and 2010-01-04. Example: Value DateTime A 2010-01-01 14:55:12 B 2010-01-02 14:55:12 C 2010-01-03 14:55:12 D 2010-01-04 14:55:12 E 2010-01-05 14:55:12 Thanks! ----

  • Getting difference between two dates Android 2011-08-01

    Am having string posting date like : 2011-03-27T09:39:01.607 and There is current date . I want to get difference between these two dates in the form of : 2 days ago 1 minute ago etc.. depending posting date. Am using this code to convert posting dat

  • Calculating how many days are between two dates in DB2? 2012-03-02

    I need to get the difference in days between two dates in DB2. I tried a couple of different queries but nothing seems to be working. So basically what i need to get is something like this. SELECT DAYS (CURRENT DATE) - DAYS (DATE(CHDLM)) FROM CHCART0

  • C# forms - Getting time between two dates 2012-04-28

    I'm trying to find the time between two dates, one being the current day (Today) and the other, a user defined deadline. I'm working with C# Windows Forms and I've used a "date time picker" so that the user can choose a deadline date and I've created

  • KornShell script to get files between two dates 2009-08-14

    Need to get the files between two given dates via a KornShell (ksh) script. If there are multiple files on one day get the latest of the files for that day. --------------Solutions------------- I haven't tried it out, but there's a mailing list post

  • How to calculate difference between two dates 2011-08-10

    I want to calculate difference between two dates (using SQL Request) with this format "YYYY-MM-DD HH:mm:ss",the result should be in hours/minutes. example: "2011-08-02 18:00:00" - "2011-08-03 09:01:00" = 15h and 1 min 1/I haven't found a function tha

  • T-SQL - get value between two dates 2011-09-30

    I just watched such an example which shows how to get all cols by date here it is... DECLARE @MyGetDate DATETIME SELECT @MyGetDate = '2 Mar 2003 21:40' SELECT * FROM @Table WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14

Copyright (C), All Rights Reserved.

processed in 0.136 (s). 11 q(s)