|
-
May 5th, 2005, 03:03 PM
#1
Thread Starter
Hyperactive Member
Dates and Weeks
Hello,
We know that there are 52-53 weeks in an year. Now what i want to achieve is that how do i determine which date falls in which week ?
I have numbered weeks from 1 to 52. So i the date is like 1-1-2005 then it should tell me that its in "Week 1" and if date is: 8-1-2005 then it should say its in "Week 2" and so on.
Please tell me how can i do this ?
Thanks.
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
May 6th, 2005, 08:53 AM
#2
Re: Dates and Weeks
You can use the url() date function.
PHP Code:
$week_number = (int) date('W', $date);
-
May 6th, 2005, 09:17 AM
#3
Thread Starter
Hyperactive Member
Re: Dates and Weeks
Hi
it does not seems to be working. I am getting 1 as weeknumber no matter what date i put in. I am using format dd-mm-yyyy.
$date = "13-05-2005";
$week_number = (int) date('W', $date);
print $week_number;
Please help
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
May 6th, 2005, 09:20 AM
#4
Re: Dates and Weeks
You need to first convert that string to a timestamp. Does the date come from a MySql database?
-
May 6th, 2005, 10:24 AM
#5
Thread Starter
Hyperactive Member
Re: Dates and Weeks
Hi,
yes it wil come from mysql db.
Thanks
Tapan Bhanot,
CEO, Avis Software.
Website: www.avissoftware.com
-
May 7th, 2005, 05:57 PM
#6
Re: Dates and Weeks
Again, in MySql you can use a function which does this in the SQL query:
Code:
SELECT DATE_FORMAT(date, '%U');
The DATE_FORMAT() function is documented fully here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|