473,466 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get the days between two given dates (no sql stuff)

I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05

How can i do this? Any help would be appreciated.

Aug 23 '05 #1
2 1827
JAPIO wrote:
I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05

How can i do this? Any help would be appreciated.


(hope this is not some course homework...)

list ($day, $month, $year) = split('-', $date);
$t = mktime(0,0,0,$day,$month,$year+2000)

So now you have start/end. Then:

while ($start < $end) {
do_whatever();
$start += 86400;
}

And you can use date() to convert the timestamp back to
human-readable format.

/Marcin
Aug 23 '05 #2
*** JAPIO wrote/escribió (23 Aug 2005 03:08:45 -0700):
I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05


Days or dates?

For days (not tested):

<?

$begin = "23-08-05";
$end = "26-08-05";

echo ceil( (strtotime($end)-strtotime($begin)) / 86400 );

?>

I not sure though whether strtotime() works with European format.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
2
by: tasmontique | last post by:
I am working on an access 2002 flight schedule database. I am new to access but have some basic understanding of sql and vb6 code. I have learned a lot from this website. Thanks much Hopefully...
5
by: gsreenathreddy | last post by:
Hi! There are two given dates and I have to find out the working days between two dates i.e. excluding Sundays. Please help. Thank you.
2
by: pointers | last post by:
Hi, Can we get a SQL query, to display all the dates between two given dates eg. if date1=21-mar-2007 and date2=25-mar-2007 then the query should display all the dates between those two given...
3
by: John | last post by:
Hi How can I calculate days from the two dates entered in date time picker fields on winform by a user? Thanks Regards
9
by: sha2484 | last post by:
I need help to count days between 2 dates,where i want to count the days between current date and registeration date.Here is the code that i have write but it only compare the days , it do not...
3
by: pchaitanya | last post by:
I have selected some list of valid dates to a label. now i need to find first day among the given dates from label contrl i got dates from calender control by clicking for entire week.. ...
1
by: bharathreddy | last post by:
This article will explain how we can get the count of weekdays in between two dates. This will be usefull if we want to count the number of working days between two dates. Example: -------------...
2
Jerry Maiapu
by: Jerry Maiapu | last post by:
I am trying to punch into a table a bunch of dates that fall between two given dates. When compiled,no error but when on run does not do anything..(i.e nothing in the table) Can someone figure...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.