Icon

Just Some Shit I Thought And Wrote.

Getting Week Start And End Date Using PHP

I have been working on a cron to update payment cycles on a payment management system -

I have had to do this before, when I had to get week end and start dates - with the help of google I had a sample script which was about 100 lines long - Today I had to do the same but I lost my script with my old machine - after cracking my head for about 20 minutes on how im going to get this rite I came up with nifty piece of —

<?php
$this_year = date(”Y”);
$num_weeks = date(”W”, mktime(0,0,0,12,31,$this_year));

for ($x=1;$x<=$num_weeks;$x++){
    $week_number = '';
    (strlen($x) == 1) ? $week_number = "0$x" : $week_number = $x;
    $week_start = date('Y-m-d', strtotime("{$this_year}W{$week_number}"));
    $week_end = date('Y-m-d', strtotime("{$this_year}W{$week_number}7"));
    echo "$x - $week_start To $week_end
“;
}
?>

Hope y’all find it useful

Kohjinsha Netbook Concept

Dual View Netbook

This would make a pretty cool toy. Read More

RSS Photography

  • Drive-by September 3, 2010
    Morolong
  • 2 / dois September 3, 2010
    “Time and space are devices for describing relationships between objects and events. Time is an abstract device because it occupies no space and contains no intrinsic energy. It is a human invention (…) there is no such thing as empty space. Space refers to the physical dimensions of the universe, visible and invisible, the extension of mass, or […]
    UP
  • icarus sundance September 3, 2010
    "The moment we were gifted with words, we silmultaneously received imagination." - Bryce Courtnay
    æ
  • Light through my petals.........! September 3, 2010
    Sthe Ngcobo
  • Casual Day September 3, 2010
    You can't get casual than that guy..Happy Casual Day
    GLUcose D