473,378 Members | 1,409 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,378 software developers and data experts.

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.

Nov 11 '05 #1
8 1504
There are many calendar functions built into PHP
http://us3.php.net/manual/en/ref.calendar.php
I would suggest you look into those, as you may find a much better way
to do what you want.

Nov 11 '05 #2
el*************@yahoo.com said the following on 11/11/2005 16:24:
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.


http://www.php.net/mktime

Then divide by 86400 ( = 24 * 60 * 60)

--
Oli
Nov 11 '05 #3
el*************@yahoo.com wrote:
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.


Hi,

I think the most simple way is using Unix timestamps

(from http://nl2.php.net/manual/en/function.time.php)

*******************************
time() -> Return current Unix timestamp
Returns the current time measured in the number of seconds since the Unix
Epoch (January 1 1970 00:00:00 GMT).
*******************************

So code something like this:
1) Get the Unixtime for 1/1/2000 (you can calculate that only one time, and
use the number from then on hardcoded if you want)

2) Get the Unixtime for now: use the function time()

3) get the difference

4) divide it by the number of seconds in a day.

You will always get a 'dayfraction' this way, and have to do some rounding.

How you do the rounding is up to your taste of course.
(Eg, if the difference between now and 1/1/2000 is X and a half day, do you
want to work with X or X+1 ?)

Hope this helps. :-)

Good luck!

Regards,
Erwin Moller
Nov 11 '05 #4
Following on from bradb's message. . .
There are many calendar functions built into PHP
http://us3.php.net/manual/en/ref.calendar.php
I would suggest you look into those, as you may find a much better way
to do what you want.


Come off it! You'll be telling us next there is an extensive manual
available in various handy formats for instant download from the web
next.

Eee I remember when I were a lad when we had nobut beads and bits of
coloured glass and feathers handed down from father to son. And all
we'd got to code with was pneumatic riveter. All by the light of a
guttering candle stuck in a heap of mud - in hexadecimal of course.
There we were, fighting in the trenches by day, programming using with
broken matchsticks and blood soaked bandages during the night - all on
5d a day. Lah-de-dah computer geeks of today don't know they're even
born. WE didn't even have computers - but we still managed to program
even though we had to sell our own snot to pay for the fish bones to
feed the owls.

--
PETER FOX Not the same since the e-commerce business came to a .
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Nov 11 '05 #5
JDS
On Fri, 11 Nov 2005 17:06:55 +0000, Peter Fox wrote:
WE didn't even have computers - but we still managed to program
even though we had to sell our own snot to pay for the fish bones to
feed the owls.


Too much coffee today? Not enough? MP festival on the telly?

--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Nov 11 '05 #6
thanks for the replies, here's what I did. Is there any situation where
this would not give the right answer?
function get_current_day() {

$then = mktime ( 0 , 0, 0, 1,1,'00');
$now = time();

$days = ($now - $then ) / 86400 - 1;

return (int) $days;

} // end function

Nov 11 '05 #7
el*************@yahoo.com said the following on 11/11/2005 18:56:
thanks for the replies, here's what I did. Is there any situation where
this would not give the right answer?
function get_current_day() {

$then = mktime ( 0 , 0, 0, 1,1,'00');
$now = time();

$days = ($now - $then ) / 86400 - 1;

return (int) $days;

} // end function


Not sure about the -1. If today was the 2nd Jan 2000, for instance, then
your answer would be 0, but you presumably would want 1.

--
Oli
Nov 11 '05 #8
el_roachmeister wrote:
I am looking for a script that can report the number of days since
2000.


<?php
$start = strtotime("1 Jan 2000");
$finish = strtotime("now");
$diff = $finish - $start;
$days = (int)($diff / 86400);
print $days;
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Nov 11 '05 #9

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

Similar topics

4
by: alwaf | last post by:
We are busy designing a generic analytical system at work that will hold multiple analytic types over time. This system is being developed in SQL 2000. Example of table IDENTITY int ItemId ...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
8
by: Robert Misiak | last post by:
Is it possible to manually change the auto-build number used in VS.NET? Thanks, Robert
2
by: Stu | last post by:
Hi, I want to write a page to track changes on a site. How do I get the build number of the site's dll from a web page? Thanks in advance. Stu
4
by: Pietro | last post by:
Thanks for the last answer, but now how can i restart the count of the Build and Revision numbers of a dll in VS.Net. Thanks Pietro
10
by: Scott Kilbourn | last post by:
Hi, Does anyone know how to accurately calculate the number of days that have elapsed since 01/01/0000? I'd appreciate any help anyone could give me. Thanks
29
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
10
by: F6GGR | last post by:
Hello any body, Here is my problem; i use Access 2000. I have found a function named "Nb.Jours.Ouvres" (in english : "number of working days" , all days but Saturday and Sunday). The help says...
5
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.