Dates, Daylight Savings And Net Days Worked
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?
for ($dayval = $startdate; $dayval <=$enddate; $dayval+=$oneday){
if (date(I,$dayval)==0){
echo("daylight savings time<br>");
}
if(date(w,$dayval)==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,$dayval)."date: ".date("m-
d-Y",$dayval)." days worked: ".$daysworked."<br><br>");
}
View Complete Forum Thread with Replies
Related Forum Messages:
Dealing With Daylight Savings
I am looking for some advice of how to deal with day light savings. I currently store my time stamps as UNIX stamps, which seems to be a problem after the change over as the stamp is interpretted with an addional hour added to it. suggest some solutions for an easy change over that could be done that would interpret these stamps correctly? eg. Thu 03/30/2006 08:00 Fri 03/31/2006 08:00 Sat 04/01/2006 08:00 Sun 04/02/2006 09:00 Mon 04/03/2006 09:00 Tue 04/04/2006 09:00
View Replies !
Mktime/daylight Savings
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 timeand display a table with all times in between (on predetermined intervals). For example, say my first column represents Monday. right now what I am doing to get Tuesday's values is multiplying my mktime(0, 0, 0, $month, $day, $year) value for Monday by 86,400 (the number of seconds in a day). Everything works perfectly fine, except when I come across the first Sunday in April and the last Sunday in October. the April Sunday still works fine, but in October, it displays that Sunday twice. My question is how do I take into account the difference in hours as a result of daylight savings time? I know I can use "I" as the format string in date() to see if the date is during daylight savings or not, and I tried using this to make it work, but it doesn't seem to be doing what I want.
View Replies !
Daylight Savings Change
In case you haven't heard, there are new daylight savings dates this year. Is PHP ready? I'm using 5+ but this question applies to all versions. I haven't been able to find any reference on php.net about this.
View Replies !
Daylight Savings Time
PHP Code: $now = time(); // Gets current server time $open = strtotime(཈ am'); // makes a midnight timestamp $close = strtotime(ƌ am'); // makes a 6 am timestamp if( ($now < $close) && ($now > $open) ) {   // We're between the open times     echo '<html>.
View Replies !
Daylight Savings To Standard Time
SyaAdmins: Tonight 1 am "happens" twice, as will every second from 1:00 through 1:59. Although it happens every year twice, something always seems to mess up when the time "falls back" (the longest day) -- in the Spring, things just "don't happen" because 1am through 1:59:59am never happens at all [crontab misses]. Things happening twice, like automatic backups, can make for an intereting Sunday morning read of the system blogs. Why else would we run those things at such an ungodly hour?
View Replies !
VBulletin And Daylight Savings Time?
I've been programming out the time offsets for some software and want to automatically take DST into consideration. Anyhow... from my research I found out that the EU and the US are the only timezones that practice daylight savings. This means-I'm assuming-that nations such as S America and Africa do not observe DST, which leaves a bit of a problem since they are in the same time zone as the US and Europe. So this leaves me wondering, do I include it or not? I've noticed that with vBulletin and ezBoard, there's not option for me to select DST. Does anyone know if these products include it automatically?
View Replies !
PHP Daylight Savings Time GMT Alogorithm
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"; if( (date(m)>=4) && (date(m)<=10) ) // IS CURRENT DATE INSIDE OF APRIL->OCT WINDOW? { if( (date(m)>4) && (date(m)<10) ) //IS CURRENT DATE INSIDE MAY->SEPT WINDOW? { $in_dst="true"; } elseif($date(m)=="4") //IS IT APRIL? { if( (date(j)<=7) && (date(D)=="Sun") ) //IS IT THE FIRST SUN OF THE MONTH? { if(date(H)>"1") //IS IT PAST 2:00AM? { $in_dst="true"; } } } elseif($date(m)=="10") //IS IT OCT? { if( (date(j)<=25) && (date(D)=="Sun") ) //IS IT THE LAST SUN OF THE MONTH? { if(date(H)>"1") //IS IT PAST 2:00AM? { $in_dst="false"; } } } } if($in_dst=="true") //INSIDE OF DST { $date=date("Y:m:dH:i:s",time()-18000); //CHANGE NUMBER OF SECONDS HERE TO MODIFY } else //OUT OF DST { $date=date("Y:m:dH:i:s",time()-21600); //CHANGE NUMBER OF SECONDS HERE TO MODIFY } ?>
View Replies !
Daylight Savings Time In Chile
I'm using a daylight savings script I found, and I adapted it so that it adjusts the time in my country (Chile). The issue is that the script is set to switch to DST starting on the last Sunday in October until the first Sunday of April. The DST in Chile starts on the second Sunday in October until the second Sunday of March. Code:
View Replies !
Server Is Returning Daylight Savings Time (DST) Or Not
For each user of my system I store the basic GMT offset (i.e. -0700) so that I can record event times using the correct local date and time for that user. Twice a year this offset changes and I want to avoid having to update them manually. All I need is a way to ask whether the server is returning daylight savings time (DST) or not when asked for the date and time. I have looked carefully through my copy of the PHP docs but can't find any way to determine the server setting. Is there any way to ask this question of a Linux/Apache server using PHP or any other method?
View Replies !
Calculate Days Worked
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead['lead_date']; I need to be able to calculate how many days that lead has existed. $row_rsLead['lead_date']; outputs as 2007-06-14. I have made numerous attempts to create a function that will calculate the days between the lead_date and today's date, but have made absolutely no headway. I am either stuck working between differing date formats or really strange numerical outputs. If there is a script someone is willing to share or point me in a direction that is good for a relative newcomer to PHP,
View Replies !
Compute Current Time For Mountain Standard Time With Daylight Savings (MDT)
I'm trying to compute current time for mountain standard time with daylight savings (MDT);and without DST (MST), eg: Phoenix, AZ. If I use the PHP timezone "US/Mountain", it returns MDT correctly. What is the PHP time zone for MST? Similarly, are there PHP time zones for Pacific, Central and Eastern time zones without Daylight Savings? The PHP time zones US/Pacific, US/ Central and US/Eastern all show time with Daylight Savings.
View Replies !
Dates Of $day In The Next $n Days
how would I go about working out the dates (timestamps) of the day $day (e.g. Monday, Tuesday, &c) in the next $n days. So if $day was Monday and $n 28 I would want to find out the dates in the next 28 days that are a Monday. The problem is that I am not sure about the logic side of the problem. A crude solution that I can think up is doing something like PHP Code:
View Replies !
Calculating Days Between Two Dates
I need to calculate the numbers of days (only the number of days) between two days, one a variable $row['user_cp_name'] in the format MM/DD/YY, and another, the current time. I've tried a bunch of tutorials on the internet and none seem to work properly.
View Replies !
Number Of Days Between Two Dates
I have spent forever trying to figure this out.. There has to be a simple way. My dates are in the format m-d-y 06-22-07 I want to know the number of days between 05-23-07 and 06-22-07. this should equal 30. I am trying to figure out how to get that with PHP.
View Replies !
Retrieve Number Of Days Between Two Dates
I am trying to write a script that grabs todays date and then counts the number of days between today and a date in the future. Both the future date and the number of days interval are retrieved from a database (MySQL). PHP Code:
View Replies !
Dates - Detect Groups Of 7 Days
i'm developing a reservation system for a vacation house. the owner has specified that the place can only be rented by the week, check-in is on saturday, then check out must be on some following saturday (doesn't matter how many weeks as long as check-out is on a saturday). i tried to figure out if the user has selected spans of seven days (rented it for 1,2,3 weeks etc...) this way: PHP Code:
View Replies !
Calculate Number Of Days Between Two Dates
I have people posting ads and when the ad is posted I have two fields populated at that time: date_created date_expired With the date expired being 7 days after the date created. Both are in this format: 03/12/07 What I am doing is preventing someone from posting more than one ad per 7 days. I'm validating against their email address for that. But I want to display the date that they would be eligible as well as determine if they are eligible to post or not which would require comparing today's date with probably using the now() function against the date_expired in the database. If the today's date is past then no problem. If not, then it would display an error. Code:
View Replies !
Working With Dates - Set Up A Cron Job That Will Close All Auctions That Are 10 Days Old
I am writing a new auction script for my website and I have everything working except closing the auctions. I have the database set up to record the start time like this: Field    Type     Default time    datetime   0000-00-00 00:00:00 I want to set up a cron job that will close all auctions that are 10 days old. My only problem is I don't know how to write the code the find the 10 day cutoff. I know I need to somehow take today's day and subtract 10 days from it but I can't seem to find out how. My plan is once I find that code I will then take that variable and compare it to the time in the database with >.
View Replies !
How I Could Compare Two Dates To Find The Number Of Days That Seperate Them.
I was wondering how I could compare two dates to find the number of days that seperate them. For instance, after a user signs up to my website, they would see a specific message for only a week. Obviously this is easy if they signed up on the 14th and today is the 16th, but what about if they signed up on the 29th, then I need to figure out for the next month.
View Replies !
Have You Worked With Punbb?
I'm looking into BBs that I can modify to suit my needs. I came across PunBB which I'd never heard of before. Have you worked with this Board and can you shed some light on it's performance, flexibility, security, and ease of use?
View Replies !
Memory Savings
Is there any memory savings by passing data back from a function ByRef versus a standard return? The reason I ask is that my script is now dealing with larger datasets and I'm starting to get PHP's 8 meg barrier error. I've gone through and UNSET any large varaibles that the script held that were no longer needed and that seemed to help a bit (didn't see the error as much).
View Replies !
PHP CLI - Can It Worked As Shared Application ?
I have an a couple of utilities I would like to create for a customers that convert data from a CSV file to an ODBC datasource. I have a protoype working on my laptop, but when I install these at the client's site, I was wondering if I could install PHP on their server and have selected workstations "share" access to the PHP interpreter or does each workstation need there own copy/installation of PHP ? BTW, I will be using the Windows version in all cases. In other words from the workstation, I would like to execute a script with a command like "J:phpcliphp.exe myscript.php"
View Replies !
Has Anyone Worked With Sessions & Classes?
do you have any code examples of how you made sessions work within classes? I've been having a lot of trouble with this and am hoping someone will have a solution (if it's possible). What I'm trying to do is create a class that pretty much is the heart of my application and I'd like to do all the session work in this. So far in my research and testing development, I've come up with the following: PHP Code:
View Replies !
RewriteRule Worked Once, Alas No More
mod_rewrite is not easy, but I'm having a doozy of a time getting the simplest rule to work: RewriteEngine on RewriteRule ^/dis.php /dls.php ErrorDocument 404 /404error.php This is to correct a common spelling error. I keep getting the 404 document. The rewrite worked ONCE sometime in its 2 hour creation process, but then stopped working so I've pared it down to the bare essential. I've been starting at a screen for aforementioned 2 hours and my eyes are about to fall out. Code:
View Replies !
Time Worked On Easy But Not Now
When i started to build my site I used easyPHP. For those of you who dont know what easyPHP is, its basically Apache, mySQL and PHP all in one. I've now bought the domain, webspace etc and somethings now not working correctly The trouble i am getting is that if i had a simple query such as: $result = mysql_query("SELECT DATE_FORMAT(timeadded, '%H:%i) AS time1 FROM bands", $connection); $row = mysql_fetch_array($result); $timeadded = $row['time1']; echo $timeadded; If would work on easyPHP but it doesnt work now :-S $timeadded is empty. I've checked the database and theres definitely a value in there. This problem is only occuring on the time. Its fine with dates etc.
View Replies !
Data Transfer Worked In 4.4.4
I am passing data from an embedded device using Content-Type = multipart/form-data. My data passed nicely into $ variables when the server ran with PHP 4.4.4 but now that it is upgraded to 5.2.3 none of the data is passing.
View Replies !
Getimagesize-worked On Osx But Not Linux For Flash
is there any way to get get the dimensions of a flash video including flash 6, the thing is getimagesize worked for flash 6 files on my osx computer but my linux wont do it even though they are running the same apache and there is only an extremely small difference in versions difference in php versions(4.3.2 compared to 4.3.3) so if there is another way to get the dimensions with php could someone tell me, i can't find a way to do it and i know this has been asked a million times but i can't find the answer i have a site i'm hosting and have decided move it to linux, but when i did that 1/2 of the flash files just stopped working with getimagesize, so it this a bug in php 4.3.3 that wasn't in 4.3.2 my os x server says Apache/2.0.47 (Unix) mod_ssl/2.0.47 OpenSSL/0.9.6e DAV/2 PHP/4.3.2 and my linux says Apache/2.0.47 (Unix) PHP/4.3.3 is it one of those modules in my osx computer that made getimagesize work.
View Replies !
Sessions Not Saving, Worked On Windows, Not On AIX
Developed on Windows (apache/mysql, no register globals or other nonsense) Moved everything to AIX and have the following problem: Nothing is saved in my session folder. Yes, I've created the directory. Yes, the apache/mysql/php user has write access to that directory.
View Replies !
Variation Of This Script Worked For MySQL
I edited this script changing the parts which should hypothetically make it work with MS SQL... But it doesn't work. Is there something glaringly wrong or missing? It worked like a charm when I had everything coded for MySQL.. Code:
View Replies !
Date/Time Worked Calculation
I`m trying to write a function to calculate the hours worked by day or night and how much a person get paid according to the following criterea: daypay is when worked between 8Am and 8PM and nightpay is when worked between 8PM and 8AM. Sometimes the person starts just before 8PM and continue work untill after 8PM , or starts his duty after 8pm and ends before or after 8am next day. Here is what I tried to do so far , yet its not working for all cases endtered. Code:
View Replies !
Ordering A Table From A Ratio Worked Out By Data In SQL
I have a SQL database that stores wins and losses, what I wish to do is order it in a table, so the people with the BEST ratio are at the top. I don't know how to do this, at the moment it's just ordered by the most wins, then the ratio on the end of the table worked out using some basic PHP. Here is my code:
View Replies !
Timezone And Daylight ST
I have a calendar application but need to let users display their entries based on timezone (for every timezone). I store all time related data (like appointments) in GMT time in a DB table. When i try to adjust this data based on timezone it is incorrect because it is daylight savings time in my timezone (EST). So for example: gmdate("F jS, Y H:i:s", time()) -> "July 14th, 2002 19:45:40" gmdate("F jS, Y H:i:s", time() + ( -5 * 3600)) -> "July 14th, 2002 14:45:40" gmdate("F jS, Y H:i:s", time() + ( -8 * 3600)) ->"July 14th, 2002 11:45:40 " This is incorrect as GMT-5 today should be 15:45, GMT-8 should be 12:45 It is not taking in account for DST. What makes this more difficult is DST start and end dates are different all aroudn the world. my question is how do you compensate for DST based on a timezone? I know how to tell if my server is currently in DST using the 'Z' option, but this doesnt mean other timezones around the world are in DST does it? How does this Bulletin board compensate for Daylight Savings time and timezone?
View Replies !
Daylight Saving
i still have the problem with daylight saving last Sun of March will increase 1 hour of the normal time and first Sun of Oct will set back to normal time: I try date("I") and it's doesn't work.
View Replies !
Offering Dates And Booked Dates In A Table As DATE Datatype Using MYSQL.
Availability dates in offering dates except booked dates. For Example: Offering dates are : 01-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 Booked dates are : 10-09-2005 to 23-09-2005 Availability dates should be 01-09-2005 to 09-09-2005 24-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 I am storing offering dates and booked dates in a table as DATE datatype using MYSQL. So, I want the above mentioned availability dates as a result.
View Replies !
Mktime And Daylight Saving
Is mktime() dependent on PHP or the server's OS? I just read that starting next year, the time switches for daylight saving time will be "on the second Sunday of March and end the first Sunday of November" instead of the current setup. http://webexhibits.org/daylightsaving/b.html?y=3000 I am worried because my application deals a lot with Unix timestamps, and I'm not sure how this change would affect everything. I tested the new date for daylight saving on March 11, 2007 on Windows XP and it was not correct - it is still reporting the first Sunday in April as the date of the switch. I am not sure about Unix, as I have not tested it. Additionally, I am using php 4.3.10, so if it is in fact PHP version dependent, I'm not sure what I can do without upgrading.
View Replies !
Daylight Saving Time
my php (4.3.4) is giving confusing results for times, switching (apparently at random) between daylight savings time and normal time. The following code gives a summertime result for a couple of days (e.g. "Mon, 4 Jun 2007 23:01:25 +0100"), then normal time (e.g. ".... 22:01:25 +0000"), and so on: $timenow = time(); echo date("r",$timenow); It happens regardless of browsers and machines. My hosting provider has no idea how this is happening, nor do I. The timestamp would be the same in both formats (right?), so I'm guessing it must be something in the php setup that determines whether it displays as summertime or not, and this is somehow getting messed up. But I know nothing about the server side of things. Is there anything I can point the server people to that might solve this?
View Replies !
Gmdate And Daylight Saving...
$date = gmdate("Y-m-d H:i:s"); To give posts on my website timestamps. The problem is, its one hour behind. Is this because gmdate doesnt account for daylight saving time? And if it is and I do H+1 then I shall haveto change it every 6 months shant I? That cant be right.. so err.. what am I doing wrong?
View Replies !
Daylight Saving Time Problem
I've manually updated the timezone to reflect the new DST for the entire server network I'm working on. Almost everything is working correctly, except PHP's date/time functions still return dates as though DST will occur at 2:00am on April 2, 2007. This only happens when the script is executed through an http request: <?php echo date("F d, Y H:i:s", time()) . " " ; ?> on shell: [user]$ php test.php March 12, 2007 11:55:51 (correct) on web browser: March 12, 2007 10:55:11 (incorrect) What's the problem here?
View Replies !
Daylight Saving Time Being Switched At Random
my php (4.3.4) is giving confusing results for times, switching (apparently at random) between daylight savings time and normal time. The following code gives a summertime result for a couple of days (e.g. "Mon, 4 Jun 2007 23:01:25 +0100"), then normal time (e.g. ".... 22:01:25 +0000"), and so on: Code:
View Replies !
|