What I am trying/wanting to do is changing the output of this JS calendar to become the same output format as PHP's date('W').
So for example, I am using the JS calendar pop up found here: http://www.mattkruse.com/javascript/calendarpopup/
When you choose a date from the calendar, an output is automatically generated and filled into the textbox in the format day/month/year
However, I dont want the output in the datebox to be generated as day month year....instead I want the generated output to be the week number user has chosen in the calendar...
So say I choose 8th January 2011 in the calendar pop up. Currently it will fill into the textbox 08/01/11...BUT what SHOULD happen is it puts into that textbox 2 as January 8th is the 2nd week in that year...How can I do this? I am stuck because if a user's current date is end of december and End date is january of the next year PHP's date command will think we are at a new year and it will mess up...I hope I am being clear...
This is what is happening...
User interface they have 2 textboxes,
each text box is associated to a calendar pop up. T开发者_如何转开发he output somehow wont be day/month/ear but instead the week of the year...
Once user chooses their options php in the backend will see what time gap the user has chosen using the function PHP's date ('W')
I am stuck on how to change the calendar date format into php's date('W') format.
Jacob Wrights Date.format supports 'W', which gives this:
ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)
In order to do what you want you are going to have to write your own function, theres no magic built in way to do it in JavaScript like there is in php
http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
http://www.irt.org/script/914.htm
http://javascript.about.com/library/blweekyear.htm
http://www.codeproject.com/KB/cs/gregorianwknum.aspx
http://www.onlineconversion.com/day_week_number.htm - working example, you can see how they do it by viewing their source
精彩评论