473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

date difference

hi

i have developed an employee details web site. there is an option to view employee's experience.

in professional experience part i have:
start date: 01 Mar 2006 and end date:05 Oct 2006

how can i get the difference between the above dates in the following format:
days worked:x year (s), y month (s), z day (s)

please give a quick reply.

thank you
Dec 2 '06 #1
5 3851
ronverdonk
4,258 Expert 4TB
Since no one answered this (yet):

I myself use a PHP class named "Simple Date Time Object" that does all my date/time calculations, also the one you are asking for. You'll find this class at STDO class

The function you look for is the "diff_MySQL function" (don't be mislead about the word MySQL, it handles you dates fine in the format YYYYMMDDHHMMSS).

Sorry I couldn't show you any code for this.

Ronald :cool:
Dec 3 '06 #2
Hai Use this code it's working perfeclty........i done this same type of application

$database_date=$acess[3];
$database_date."<br>";
$check_date=explode("-",$database_date);
$current_year=date("Y");
$current_month=date("m");
$current_day=date("d");
$end_year=$check_date[0];
$end_month=$check_date[1];
$end_day=$check_date[2];
$current_date=gregoriantojd($current_month,$curren t_day,$current_year);
$final_date=gregoriantojd($end_month,$end_day,$end _year);
$possible_acess_date=$final_date-$current_date;

Sasi
Dec 4 '06 #3
thanks for the reply. but i failed to understand the usability for date in which format (i.e. [26 Feb 2006] or [Feb26 2006] or [26/02/2006] ).

it will be great if you explain with a date example.

thanks

Hai Use this code it's working perfeclty........i done this same type of application

$database_date=$acess[3];
$database_date."<br>";
$check_date=explode("-",$database_date);
$current_year=date("Y");
$current_month=date("m");
$current_day=date("d");
$end_year=$check_date[0];
$end_month=$check_date[1];
$end_day=$check_date[2];
$current_date=gregoriantojd($current_month,$curren t_day,$current_year);
$final_date=gregoriantojd($end_month,$end_day,$end _year);
$possible_acess_date=$final_date-$current_date;

Sasi
Dec 4 '06 #4
Hai ...

GregorianToJD this is php function...

this function syatax is
gregoriantojd(month,day,year);

....

so i get in the curret date value is first value

$current_year=date("Y");
$current_month=date("m");
$current_day=date("d");

$current_date=gregoriantojd($current_month,$curren t_day,$current_year);

the second i get database value.....

split the database value in our form using explode function

$database_date."<br>";
$check_date=explode("-",$database_date);
$end_year=$check_date[0];
$end_month=$check_date[1];
$end_day=$check_date[2];

after just subtraction of two value

$possible_acess_date=$final_date-$current_date;

this is given some numeric number....

u want year wise means

$year=$possible_acess_date/365;

do u want month wise means
$month=$possible_acess_date/30;

that'a ll
Dec 4 '06 #5
ronverdonk
4,258 Expert 4TB
I fail to see how a Gregorian to Julian date function can help with the problem in this thread.

(ctsasikumar: before you dump any code in this forum, read the Posting Guidelines at the top of this forum!! And extra attention for the part about enclosing shown code within php, code or html tags!)

Ronald :cool:
Dec 4 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
5
by: tamilan71 | last post by:
Hello All I have table with following fields: GroupId VisitDate 1 10/19/1993 1 11/24/1998 2 10/18/1993 2 10/29/1998 3 ...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
16
by: Atley | last post by:
I am trying to get a overall difference on two dates, I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, Seconds, no problems... What I cannot seem to figure out is how to...
6
by: Scott | last post by:
I have a start date and an end date in my project that is defaulted to the current date at run-time using the following code... Date1.Value = Now() Date2.Value = Now() I then have some code...
13
by: priyasmita_guha | last post by:
Here is a program- /* PROGRAM: To find the difference between two dates */ #include<dos.h> #include<stdio.h> #include<conio.h> #include<process.h> void valid_date(int,int,int); int...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
7
by: rdawadiuk | last post by:
hi, I would like to calculate the date difference between two dates using field names which I have in my table. The field name is " Account opened on" for eg If the "Account open on" is Jan 5,...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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,...
0
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
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,...

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.