473,748 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dates, daylight savings and netdaysworked

Gil
I'm trying to mimic the functionality of netdaysworked in excel. The
code below works, except when the date starts during daylight savings
time. what is the number of seconds in a day for a daylight savings
day?

thanks,
gil

for ($dayval = $startdate; $dayval <=$enddate; $dayval+=$oneda y){
if (date(I,$dayval )==0){
echo("daylight savings time<br>");
}
if(date(w,$dayv al)==0){
$daysworked = $daysworked+0;
}
elseif(date(w,$ dayval)==6){
$daysworked = $daysworked+0;
}
else{
$daysworked++;
}
echo("first day: ".$dayval." number of days ".($dayval/86400)."
lastday : ".$lastday. "day of week :".date(w,$dayv al)."date: ".date("m-
d-Y",$dayval). " days worked: ".$daysworked." <br><br>");
}

Jun 21 '07 #1
1 1649
Gil
On Jun 21, 1:42 pm, Gil <gilbert.mil... @gmail.comwrote :
I'm trying to mimic the functionality of netdaysworked in excel. The
code below works, except when the date starts during daylight savings
time. what is the number of seconds in a day for a daylight savings
day?

thanks,
gil

for ($dayval = $startdate; $dayval <=$enddate; $dayval+=$oneda y){
if (date(I,$dayval )==0){
echo("daylight savings time<br>");
}

if(date(w,$dayv al)==0){
$daysworked = $daysworked+0;
}
elseif(date(w,$ dayval)==6){
$daysworked = $daysworked+0;
}
else{
$daysworked++;
}
echo("first day: ".$dayval." number of days ".($dayval/86400)."
lastday : ".$lastday. "day of week :".date(w,$dayv al)."date: ".date("m-
d-Y",$dayval). " days worked: ".$daysworked." <br><br>");
}
I solved the problem...

$sm = date("m",$start date);
$sd = date("d",$start date);
$sy = date("Y",$start date);
$em = date("m",$endda te);
$ed = date("d",$endda te);
$ey = date("Y",$endda te);
$stjd = gregoriantojd($ sm,$sd,$sy);
$edjd = gregoriantojd($ em,$ed,$ey);
echo ("julian start date: ".$stjd."<br>") ;
echo ("julian end date: ".$edjd."<br>") ;
echo ("days between :".($edjd-$stjd)."<br>");
for ($dayval = $stjd; $dayval <=$edjd; $dayval+=1){

if (jddayofweek($d ayval)==0){
$daysworked = $daysworked+0;
}
elseif (jddayofweek($d ayval)==6){
$daysworked = $daysworked+0;
}
else{
$daysworked++;
}

Jun 21 '07 #2

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

Similar topics

1
2619
by: Marcus | last post by:
Hi all, sorry to post yet another unix timestamp question, but I've been looking through php.net and google and can't find exactly what i need... plus I think my brain has shut down from too many hours of php code... :-) Anyways, here is my problem... I am displaying an HTML table that represents a person's schedule for the week... I query a database and take the absolute earliest starting time, absolute latest ending time, and display...
3
3667
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for any other U.S. timezone by changing the number of second subtracted at the end. <? $in_dst="false";
2
7214
by: hourang | last post by:
ok im getting tired of looking for an answer and coming up short with scripts that dont work. i have a application that uses GMT for all its times and needs the clients timeoffset for showing the correct times for everything. i use date.getTimezoneOffset() which works fine and shows the daylight savings time correct value of -4 since im in eastern standard time and its daylight savings time right now. well eastern standard time is...
1
7849
by: Ernie | last post by:
I am creating an .ics file that when opened (via Outlook) inserts a meeting into the calendar. All works fine unless the date and time I'm inserting happens to occur on the hour the time changes due to daylight savings. For example in 2004 the hours changed at 2:00 AM on April 4th (the first Sunday of April). Only on this day, if the start hour is 2 (2:00 AM, 2:15 AM, 2:45 AM), then an extra hour gets added so that 2:00 AM becomes...
10
5264
by: Marc Pelletier | last post by:
Hello, I am writing an application that does some simple astronomical calculations. One of the variables I need is the number of hours passed in this year. I've written the following function public static double GetHoursofYear( DateTime aTime ) { DateTime StartYear = new DateTime( aTime.Year, 1, 1 ); return ( aTime.ToOADate() - StartYear.ToOADate() ) * 24;
3
3259
by: chrisdevey | last post by:
Is there any way to make a System.Timers.Timer adjust for daylight savings time change? In a long running process I set a timer as follows for a daily expiration: _myTimer = new Timer(_myTimerDelegate, null, nextExpiration, TimeSpan.FromDays(1)); When we make the change out of daylight time back to standard time, the timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is there a way to set this timer so that it is...
3
4326
by: mmuras | last post by:
I did not see any discussions / threads for this but if there is one please let me know: -First, I am one of only two individuals within my company's IT Dept. -We have a Windows Server 2003 R2 Standard Ed. Box for our Domain controller. -We are having issues STILL today in April with the Microsoft Windows Daylight Savings Issues ***Symptoms:
9
21385
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by the number of seconds in a day? - Clint
3
482
by: Generic Usenet Account | last post by:
Hi, Is there any way to make time-of-day adjustments for daylight savings using only standard time functions? We have a program that executes daily at a fixed time of day. After daylight savings happens, the time-of-day alignment is lost. For example, if the daily task gets kicked in at 9 p.m. every evening, after daylight savings ends in fall, the task is shown as kicking in at 8 p.m. Similarly, if the daily task gets kicked in at...
0
8991
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
9552
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
9376
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
9326
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
8245
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
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.