Date question.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
$0.05$
Forum Newbie
Posts: 5
Joined: Fri Sep 27, 2002 10:54 pm
Location: Canada
Contact:

Date question.

Post by $0.05$ »

How would i find out the number of days since... any given year?

IE. the number of days that have passed since 1900.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

try the date functions...
http://www.php.net/manual/en/function.date.php

(you can supply it the current timestamp, with an offset to make it right to be from whatever time you want it to be...
as to the exact numbers i couldnt tell you, but i think that the manual should help (you can use recursive date functions
:
date(mktime(date(......))) ) )
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

uhm... simple math..

Code: Select all

$year = date("Y");
$year = $year - 1900;
$final = $year * 365.25;
echo $final;
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

um...this will sound idiotic but why did u you use 365.25? 8O
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

qads, because that's how many days are really in a year. however, just try making a calendar to accomadate that. so we round down to 365 days in a year. but over time this would really mess us up so every four years we add an extra day (leap year) to make up for the round down (.25+.25+.25+.25 = 1). i could go on forever about this but i hope that answers your question
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

there 365 1/4 days in a true year, but we just round down, and put an extra day on every four years..
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Basic Science...
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i see 8O ....thanks guys.
Post Reply