Caution with the date does not hurt

    imageFor my project, in php, I always need to know exactly what week number is now. I used the date () command to do this and got the year and week number. For example, December 22, 2008 was 52 weeks of the year. it was just wonderful everything until the 29th came. Because December 29, 2008 is like week 00, which is, to put it mildly, wrong. Therefore, I finally became convinced that data is not suitable for accurate and calendared calculations. The strftime ('% W') function is most suitable;


    A small test showed that now it makes more sense

    strftime(’%W’, strtotime(“12/29/2008″)) // 52

    strftime(’%W’, strtotime(“12/31/2008″)) // 52

    strftime(’%W’, strtotime(“1/1/2009″)) // 00

    strftime(’%W’, strtotime(“1/5/2009″)) // 01



    Also popular now: