473,797 Members | 3,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An easy Question should mean an easy answer

I am only asking for my code to do a simple thing but for some reason i
just can't get it to do what i want it to do... it been bugging me all
day!

The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days that there
are between these two dates, inclusive. For example:

01/01/2005
03/01/2005
= 3 days

Also over a month change..

27/03/2005
02/04/2005
= 7 days

I can't see anywhere on the forum a successfull version of this in PHP
code.

please Help!
Thanks
Ben

Jul 17 '05 #1
6 1363
Sorry, as you may well tell i am a newbee.
is ther eanywhere i can get instructions on what to do with this file?
wher eis the location it needs to go and how do i call it?

Thanks for this help

Jul 17 '05 #3
"ben3003" <go****@benhend erson.co.uk> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
I am only asking for my code to do a simple thing but for some reason i
just can't get it to do what i want it to do... it been bugging me all
day!

The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days that there
are between these two dates, inclusive. For example:

01/01/2005
03/01/2005
= 3 days

Also over a month change..

27/03/2005
02/04/2005
= 7 days

I can't see anywhere on the forum a successfull version of this in PHP
code.

please Help!
Thanks
Ben

Convert the two dates to a unix timestamp, subtract them, and you'll get
your answers in seconds. As long as both dates are after 1969, you'll be
fine.

-Joe
Jul 17 '05 #4
NC
ben3003 wrote:

The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days
that there are between these two dates, inclusive. For example:

01/01/2005
03/01/2005
= 3 days


Actually, this would be 60 days; 03/01 would be interpreter
as March 1, not January 3...

Anyway, here's what you need:

$date1 = '01/01/2005';
$date1 = '03/01/2005';
$days = round((strtotim e("$date2 23:59:59") -
strtotime("$dat e1 00:00:00")) / (24*60*60));

Cheers,
NC

Jul 17 '05 #5
ben3003 wrote:
I am only asking for my code to do a simple thing but for some reason i
just can't get it to do what i want it to do... it been bugging me all
day!
The complexity of a question is in no way related to how succinctly you
can state the question!

compare:
"Why do we think gravitation and acceleration are equivelant?"

with:

"What is 89 plus 5?"
Finding the difference between dates isn't trivial, although it is a
commonly required task...

The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days that there
are between these two dates, inclusive. For example:

01/01/2005
03/01/2005
= 3 days

Also over a month change..

27/03/2005
02/04/2005
= 7 days

I can't see anywhere on the forum a successfull version of this in PHP
code.

please Help!
Thanks
Ben


Jul 17 '05 #6
On 17 Mar 2005 14:08:58 -0800, "ben3003" <go****@benhend erson.co.uk> wrote:
The user inputs 2 dates on one page. in the form xx/xx/xxxx
I then want the output page to display the amount of days that there
are between these two dates, inclusive. For example:


Check out www.phpclasses.org. A search on 'compare date' turns up a number of
classes that accomplish this sort of thing.

HTH
Jul 17 '05 #7

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

Similar topics

4
1925
by: Derek Wickersham | last post by:
Easy newbie question. I've searched all the PHP documentation I can find, but can't find an answer. What does the "@" mean, in this context: @mysql_select_db( "scripts");
9
6512
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I plan to keep, to be saved to a database (as a reference in a table to a common table as a part of...
9
3207
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is indeed also true for our language of choice, Python. Its file type allows some extraordinary convenient access like: for line in open("blah"): handle_line(line)
9
2024
by: Weekend | last post by:
Currently, i want to develope a multiple choice exam website. The content of the test is store in an XML file. I want to carry out some function. Could you tell me which programming language should i use? 1.A page that display the content of the XML file. (JavaScript, JSP, XSL, DOM, DSO ActiveObject control ?) 2.A page that Give the feeback to the users who finished the exam. (this part i would like to use JSP) 3.A page that enable me to...
3
9256
by: Oliver Bryant | last post by:
I just finished developing a javascipt component allowing floating captions to appear over HTML elements. If anyone wants to check it out you can see specs and download it from http://boxover.swazz.org. There is a demo there as well.
5
13721
by: mp141 | last post by:
Hello, I was wondering if there was an easy way for me to calculate the mode for a field of values in one query. I have one field of values say Names and all I want it to return is one record of the most common name in my Names field. I tried a count function subquery within a max function but it returns an error that I cannot aggregate functions... *shrugs* I am quite a newbie at this so please forgive my ignorance. Any help is much...
18
40008
by: Mike Bartels | last post by:
Hi Everyone! I have two Arrays A and B. Both arrays are byte arrays with 7 bytes each. The contents of array A and B are the same A = {1, 2, 3, 4, 5, 6, 7}; B = {1, 2, 3, 4, 5, 6, 7}; When I do
6
2298
by: Martin Bootsma | last post by:
I have a C question, which looks very easy, but no one here seems to know an easy answer. I have a function "powell" (from Numerical Recipes) which takes an argument of the type "double (*f)(float)" But I want to be able to pass a
12
4039
by: kostas | last post by:
Hi I was asked to propose an interview question for C/C++ programmers (CAD/CAE software) I came up with the following ---------------------------------------------------------------------------------------- float fun(float value) { float f1 =0., f2 = value; float tol = value/1000.; float result,tmp;
20
2911
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going through some LINQ queries. But how to cast? ( See the below, modified from somebody else's code. The problem is the query 'stops' (throws a cast exception) at "3", and never gets to "violet".
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.