Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Working Out Days Elapsed.


in mysql i have 2 files (date files) they are:

1)2007-08-27 13:20:03
2)August 13, 2007, 10:02 pm

they are displayed differently, is there a way i can work out the days elapsed between them like this? or do the time stamps need to be the same?




View Complete Forum Thread with Replies

Related Forum Messages:
Determining The Number Of Days Elapsed?
I have a start date and an end date. I am using the following php code to determine the number of months elapsed:

$elapsed = $year1 *12 + $month1 - $year2 *12 + $month2;

This code works great. However, what tweaks would I need to make to determine the number of DAYS elapsed?

View Replies !
Working Days
I need to setup a script to run on the FIRST WORKING DAY of each month. I will have the script running as a cron. I was thinking the easiest way of doing this would be to have a bit of php inside the script that detects to see if the day is the first working day of the month and just run the cron every day.

View Replies !
Is There An Easy Way To Populate This Array With Only The Working Days?
Is there an easy way to populate this array with only the working days (no Sat or Sun) from the last 60 days. for($i = 1; $i <= 60; $i++) { $pastDates = date("Y-m-d", mktime(0, 0, 0, date("m")-2, date("d")+$i, date("Y")));

$findPastDates = array($pastDates);

}

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 !
Elapsed Time
Does anyone have a good Elapsed Time Function? I pulled a couple from Hotscripts but they have problems with certain dates. go figure. Don't have time to fix their code either. I need it to output

elapsed time: 1 year, 2 mths, 25 days, 2 hrs, 20 min

Pulling the create dtm from mysql against the current server dtm.

View Replies !
Getting The Elapsed Time Between Two Dates
i have in my database tow fields like this "field = time1" - "type = time" and "field = time2" - "type = time1" now i want to get the elapsed time between "time1" and "time2" in time1 i have 09:10:55 and in time2 i have 18:45:55 , my code looks like this and i don't know where i am wrong:

<?
mysql_connect("localhost", "root", "") or die ("Error" .mysql_error());
mysql_select_db("test") or die ("Error:" .mysql_error());

$result = mysql_query("select * from test") or die ("Error:" .mysql_error());
$row = mysql_fetch_object($result) or die ("Error:" .mysql_error());

$tm1 = $row->time1;
$tm2 = $row->time2;

echo "$tm1<br>";
echo "$tm2<br>";

echo date("h:i:s",$tm2-$tm1);?>

View Replies !
Elapsed Time Calculation
I am developing a basic ticketing system to log customers calls on etc. I have a MySQL table that stores the time the ticket was created/logged in a MySQL timestamp IE NOW() which gives the value of something like this: 2005-08-26 19:45:11

I am wanting to figure out how long it has been since this ticket was generated (Age of ticket) since the date it was created, can anyone help me out ? I have trawled the web for a solution but as yet have come up with very little.

View Replies !
Impossible Elapsed Time
How is this possible:

$start_time=microtime(TRUE);
$success=InitArchive(1,1,20);
$end_time=microtime(TRUE);
$elapsed_time=$end_time-$start_time;

Sometimes the elapsed time is negative.

View Replies !
Current Elapsed Time
Is there any function available using which I can know execution time elapsed for current page. This is in reference set_time_limit. I want to to know How many seconds are remaning for time out of current page? Or I will have to use time function and find out time.

View Replies !
Elapsed Time And Random Selecting
1. Im trying to get code for an elapsed amount of time. For example, I have a date in my database and if that is not updated in 30 days, the "active" field changes to "no" or whatever. I don't know if I've explained that carefully enough, but does anyone know how I can achieve this?

2. If I make a table with lets say 20 questions, what code can i use so that when someone requests, only 10 (random) questions appear?

View Replies !
Elapsed Time Function - How Do I Convert It To Only Total Seconds?
Below is a good elapsed time function I found. However, I'd like to return
total seconds instead of broken down into days, hours, minutes & seconds.
In other words, I want "125" instead of "2 minutes 5 seconds".

function calcElapsedTime($time)
{ // calculate elapsed time (in seconds!)
$diff = time()-$time;
$daysDiff = floor($diff/60/60/24);
$diff -= $daysDiff*60*60*24;
$hrsDiff = floor($diff/60/60);
$diff -= $hrsDiff*60*60;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;
return ('(elapsed time '.$daysDiff.'d '.$hrsDiff.'h '.$minsDiff.'m
'.$secsDiff.'s)');
}

View Replies !
How Do You Add 7 Days To Now()?
How do you add 7 days to the now() function stored in database as 00-00-00 00:00:00

View Replies !
Last 7 Days
I am trying to run a query to get the last 7 days in the following format: Code:

<a href="roundup.php?news_date=20060523">Tuesday, May 23, 2006</a><br>
<a href="roundup.php?news_date=20060522">Monday, May 22, 2006</a><br>
<a href="roundup.php?news_date=20060521">Sunday, May 21, 2006</a><br>
<a href="roundup.php?news_date=20060520">Saturday, May 20, 2006</a><br>
<a href="roundup.php?news_date=20060519">Friday, May 19, 2006</a><br>
<a href="roundup.php?news_date=20060518">Thursday, May 18, 2006</a><br>
<a href="roundup.php?news_date=20060517">Wednesday, May 17, 2006</a><br>

View Replies !
How To Get -7 Days
how can i query the last seven days of my table

(table )waytogo
id (int auto increment) | dates (datetime format)
1 | 2005-11-23 08:54:32
2 | 2005-11-21 09:32:45
3 | 2005-11-12 12:43:22
4 | 2005-11-19 02:30:00

etc...

View Replies !
Days In A Calender
I am trying to write a calender display that shows the days of the month accross the top of a table, and people's names down the side. One of the things I would like to do is to change the colour when the days are Saturday or Sunday. PHP Code:

View Replies !
Get The Birthdays For The Next 14 Days
I have a table of members and I have their dob. Now I want to show the members which have their birthday in the next two weeks. PHP Code:

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 !
Add Days To Date
I have a date assigned to a variable $firstPay and another variable $totalDaysTo which has the number of that I want to add to the variable $firstPay to get some future date. I'm not sure how to wright the code for this one.

View Replies !
Days Calculation
i can't seem to get this what im trying to do is work out the elapsed time in DAYS from 2 dates code is:

             $time_now = time();
             $d2 = date('Y-m-d H:i:s', $time_now);
             $d1 = date('Y-m-d H:i:s', strtotime($ng_date));
             $days = ceil(($d1 - $d2) / (60 * 60 * 24));
when echoing out it produces:

2007-06-02 16:53:24
2007-08-27 18:00:51
which is right, but $days echoes out as 0.

View Replies !
Days Of Week
I'm attempting to display information for today, the next day and the day after (so only three days worth). The first day is hardcoded to say now. I want the next day and the day after to be the abbreviated day (ie. Tue, Wed and so on). The problem I have with the following code is that now and the next day are the same. Thus, I have now (which is Tue), the next day (which is ALSO Tues - wrong!) and the day after is Wed. Here's the include:

$return['mydata'] = array();
for($i = 0; $i < 2; $i++) {
$attr = explode('"', $this->tag('blm:mydata',$i));
if(count($attr) > 1) {
$day = array();
$day['when'] = $attr[1];
$day['image'] = IMAGES.$this->translate($attr[11]).'.gif'
array_push($return['mydata'], $day);
}
}
return $return;

And here's the front-end page:

echo " ".$stuff['mydata'][0]['when']."<br/>

View Replies !
Select Last 7 Days
I have a load of dates in my 'orders' table in this format 2006-10-25 and i need to be able write a query that would select all orders in the last 7 days - in fat it can be any number of days but that's a variable from a select menu. what i can't work out is how to write the query :

SELECT * FROM orders WHERE ord_date ..(is between x days ago and today)?

View Replies !
Adding 7 Days
I have been tearing my hair out trying to work out how to add 7 days onto the current date. This is how i am calcualting the current date: PHP Code:

// Set the timezone for getting the currrent local time
    $timezone  = +9;

Code:
<input type="hidden" name="date" value="<? print gmdate("Y/m/d @ H:i:s", time() + 3600*($timezone+date("I"))); ?>">

This is being stored in the DB like this: Code:

$SQL = $SQL . " date_posted DATETIME NOT NULL default &#55612;&#57200;-00-00 00:00:00', ";

So, what I am trying to do is create a variable called "Expiry Date" which I want to be $date + 7 days .

View Replies !
Days Remaining
I want to find out number of days remain from birthday(any other day).

View Replies !
Days Between Two Given Dates
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?

View Replies !
Days Of Week In App
recommend for a best approach to populating a Days-of-the-Week table in an event-scheduler app? in my particular case, each day of the week relates to a daily drink-special for a bar. i'm trying to figure out my order of dependencies. here's a snapshot of my tables

if i am going to add an event,i have to have it on a day of the week. that day of the week needs to have it's specials populated in order for it to exist in the Table. so, how should i go about "forcing" the Event Scheduler App User to first populate the Days-of-Week table so that when she adds data for an event, the dayys of the week will be available to input into the Event table?

View Replies !
Strtotime With Days
On this - "next Thursday" is that next thursday or the next thursday ie: on wed will it show tomorrows time or the next week? PHP Code:

<?php
echo strtotime("now");
$timestamp = strtotime("now");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;
?>

<p>

<?php
echo strtotime("next Thursday"), "";
$timestamp = strtotime("next Thursday");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;

View Replies !
Days Miss For The Day X
I want to do a script that I show me how many days miss for X. date I tried of the following form:

<?php
$date_today = date("m/d/Y");
$date_final = date("m/d/Y", mktime(0, 0, 0, 04, 20, 2007));
echo $data_final - $data_today;
?>

But the value always returned is zero.

View Replies !
Hours To Man Days
I know this is prob easy but i've looked around and can't find what i am looking for, plus i'm a little bit of a newb. I have a group of total hours for a bunch of workers,, i.e each is like 280 hrs and i need to display these set of hours in another way, i need to display them in total man days instead and a man day for me is 6.5 hours now i know i can just divide 280 by 6.5 in php but that gives me something like:

43.076923076923076923076923076923 i need it to output in a format something like 43 days + 1 hour (or minutes if less than an hour)

View Replies !
Days Ago Calculation?
<?php
$month = 10;
$day = 17;
$year = 2006;

$days = (mktime(0, 0, 0, date("m"), date("d"), date("Y")) - mktime(0, 0, 0, $month, $day, $year)) / 86400;
echo $days;
?>

-> Take the seconds from unixtime now, minus unixtime date, split by seconds in a day = amount of days ago Problem is, the output is: Code:

View Replies !
Getting Total Days.
We have a notice form which allows people to tell us if they're going to be for a long time, containing the start day/month/year and end day/month/year. Code:

View Replies !
Date + 4 Days
I need a script that reads the current date on server and computes an additional 4 days to display a date. e.g. today 29/12/05 + 4 days, the script would display 02/01/05 (or similar depending on formatting).

View Replies !
How Can I Add 7 Days To Date ?
How can I add 7 days to this date ?

$today = date('M-j-Y');
echo $today;

Also trying to do this..

what I am trying to do is if a person cant go into a certain area for 7 days, and trying to figure out how many days he has left before he can get in..

I add the time in the db by using time()

HTML Code:

$checkdate = (time() - 604800);//todays date - 7days
and to get the time from db here is the variable:
$enterdate2

View Replies !
Working Connection... Not Working? (Advanced)
It has tons of modules, and obviously a config file which opens the db connection. But there is one, and only one, module having strange troubles.

$query is just a simple INSERT INTO command. But it does not inserts anything. I only obtain... nothing. Neither an error from the server! Code:

View Replies !
How Do You Print A Date 7 Days Ago Please?
I have this code:

$today = getdate();
$month = $today['mon'];
$mday = $today['mday'];
$year = $today['year'];

echo $year-$month-$mday

which prints out the date today (2001-10-26).

How do I get it to print out what the date was 7 days ago?

View Replies !
Number Of Days Interval?
I need to calculate the number of days between two unix timestamps. I.e., if they are from the same day, the interval is 0, if $then is tomorrow (where $now is today), the interval is -1, if $then is yesterday, the interval is 1, and so on. Here's my code:

View Replies !
How To Add X Number Of Days To A Date
I have been scratching my head over this one. I want to add a number of days to a date and end up with a date.

The only way I've thought of doing this so far is converting to a time stamp, adding the days (in milliseconds) and then converting back.
I'm sure there must be an easier way!

View Replies !
Create An Array Of All The Days
lets say i have 09/01/2001 and 09/20/2001. I want to create an array of all the days including the two that are the start and end of the range. how would i go about doing this?

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 !
Marking Calendar Days
I did a very basic calendar in php, and know I want to mark some days.
For example: -exam days, semesters, etc.
What is the best way to do this?
I want to click a link, button, checkbox,etc and marking days to a
database, either single or start and end days.

View Replies !
Subtracting Days From Date
I have a date format written in Y-m-d and I need to be able to subtract a set number of days and then display the result. I know a lot has been written about this but it has beaten me.

// get todays date
$mydate = date("Y m d");

// split into individual y,m,d
$datearr = split("-",$mydate);

// make timestamp
$timestamp = mktime(0,0,0,$datearr[1],$datearr[2],$datearr[0]);

// increment date, you can alter the number of days obviously
$newtimestamp = strtotime("-2 days",$timestamp);

// change to readable date
$mynewdate = strftime("%Y-%m-%d",$newtimestamp);

echo $mydate; // outputs 2003 09 30
echo $mynewdate; // outputs 2002-11-28

This code subtracts 2 days which is fine, but then it also subtracts a year and adds two months..

View Replies !
How Do I Display The Last 14 Days On A Page?
Does anyone know how to display the last 14 days including the current day
on a page in php? I don't know where to start with this myself.

View Replies !
How Many Days A Member Has Been Subscribed.
This may be more of a MySQL question but possibly a php solution. I'm trying do do a query to return how many days a member has been subscribed. The column date is the date they joined. Code:

View Replies !
Date Interval 7 Days
I currently have a view_jobs page, and it shows jobs booked on the current day and 7 days either side. I want to be able to only show jobs for the current day, and 7 days in the future. This all works around my date field.

My current code is:
$query = "SELECT *, DATE_FORMAT(date, '%W (%d/%m/%y)') as dateFormatted
FROM jobs
WHERE date > DATE_SUB(CURDATE(), INTERVAL 8 DAY)";

View Replies !
Displaying Records After 2 Days
I trying to display only records that are 2 days old so the owner of the site can preview new records before they are available to others, this is what I've got so far...
$sqlquery = "SELECT headline, news, date_format(date,'%M %D %Y') as time FROM $table WHERE date < NOW() ORDER BY date DESC";

is there a way to extend it by 1 or 2 days, i've tried the TO_DAY function but couldn't get it to work either.

View Replies !
45 Days Prior To Date
Been assigned a project to list entries
that have been entered within the last
45 days.

My database has the date column with the
date format as YYYYMMDD (ex: 20070423)

Been trying to write code for an SQL query
to list entries that are less than 45 days
from the date that is in the column

I have used the dateadd() function but does the
date have to be in the format as MMDDYYYY
(ex: 04232007) in order for the dateadd()
function to work properly.

View Replies !
Number Of Days In 1/1/2000
I am looking for a script that can report the number of days since
2000. It should handle leap years but I am not worried about accuracy
to the hour/minute or seconds. I am writing a calendar program and need
a reference point to base all my dates from. So I picked 1/1/2000.

View Replies !
COUNT Only Within Last X Amount Of Days
The script should grab only last 7 days of database entries which it does.  Also it also needs to count to see how many times a CD was played, which it also does, but gives overall total and not just within that 7 days. Code:

View Replies !
Days Based On Months
I am trying to modify some code so that the days dropdown has the correct amount of days for each month( Jan - 31 days, Feb 28, etc). I managed to get it so the correct days appear however it lists all the days. Code:

View Replies !
Number Of Days In Month
is the only way to find out  the number of days in a month is using this functions?

cal_days_in_month

View Replies !
Display Records 30 Days From Now
I am trying to display records that are 30 days from the current time.  Someone suggested the following:

select * from table WHERE date_column BETWEEN CURDATE() and DATE_SUB(CURDATE(),INTERVAL 30 DAY)

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 !
Constraint Using The Days Of The Week?
I am developing a property application where I have 5 members and only want 1 member a day to choose their property for the "property of week" section.

So I want to assign a day to each member.

Mem1 - Mondays
Mem2 - Tues
Mem3 - Wed etc..

Each member will have there own unique logon so if Mem1 logs in on Monday, they will have the "property of week" option avaliable to them. Mem2 will have it Tuesday and so on.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved