1. #1
    Ext User
    Join Date
    Nov 2009
    Posts
    2
    Vote Rating
    0
    anykey is on a distinguished road

      0  

    Default Get Monday of week

    Get Monday of week


    Hello,

    tried to calc the Monday of a given week/year and thought this should do (but did'nt):

    Code:
    var mow = Date.parseDate('1/48/2009','N/W/Y');
    alert('Monday of week 48 in 2009 was: '+mow.format('d.m.Y'));
    The only way to do this was this, little cryptic, code:
    Code:
    var mow = new Date().add(Date.DAY, -(new Date().getDay() - 1));
    alert('Monday of week 48 in 2009 was: '+mow.format('d.m.Y'));
    Any thoughts why the first one do not work?

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    The following date format codes can be parsed, but are not actually used to set the date:
    Code:
    D  A short textual representation of the day of the week          Mon to Sun
    l  A full textual representation of the day of the week           Sunday to Saturday
    N  ISO-8601 numeric representation of the day of the week         1 (for Monday) through 7 (for Sunday)
    S  English ordinal suffix for the day of the month, 2 characters  st, nd, rd or th. Works well with j
    w  Numeric representation of the day of the week                  0 (for Sunday) to 6 (for Saturday)
    W  ISO-8601 week number of year, weeks starting on Monday         01 to 53
    t  Number of days in the given month                              28 to 31
    L  Whether it's a leap year                                       1 if it is a leap year, 0 otherwise.
    T  Timezone abbreviation of the machine running the code          Examples: EST, MDT, PDT ...

  3. #3
    Ext User
    Join Date
    Aug 2009
    Posts
    588
    Vote Rating
    1
    Mike Robinson is on a distinguished road

      0  

    Default


    Once you have a JavaScript "date" object, you can use any of these methods to work with the date value.

    A Google search on "javascript date week" makes it very clear that you really aren't the first person to need to do what you're doing. Simply find someone else's existing code and explanation.

  4. #4
    Ext User
    Join Date
    Nov 2009
    Posts
    2
    Vote Rating
    0
    anykey is on a distinguished road

      0  

    Default


    Thanks a lot, i'm fine now.

Thread Participants: 2