0

how can i get date from week number and day number any idea ? i m able to to get week number and day number from date.

here is code to get week number and day number

date('N', strtotime($dtoday))

$duedt = explode("-", date('Y-m-d',strtotime($dtoday)));
$date  = mktime(0, 0, 0, $duedt[1], $duedt[2], $duedt[0]);
$week_current  = (int)date('W', $date);

is there any function to get date from week number and day number

day numbers r like Monday=1 and so on

Chintan_chiku
  • 425
  • 2
  • 12
  • 24
  • Well, you can't directly get date without specifying a year! – Tzar Feb 14 '14 at 09:50
  • That's rather painful. Take a date value, convert to string, then convert BACK into date values... multiple roundtrips date->string->date should be avoided like the plague. – Marc B Feb 14 '14 at 09:50
  • i dont want to use datetime object....if possible cuz it requires php 5.3 and above – Chintan_chiku Feb 14 '14 at 09:52
  • This should not be marked as duplicate as the poster mentioned that DateTime class should not be used. Here's a solution without DateTime: `$year = '2014'; $week_no = 7; $day = 5; $first = date("w", strtotime("$year-01-01")); $days = ($week_no - 1) * 7 + ($day - $first); print date("Y-m-d", strtotime("$year-01-01 +$days days"));` – Razvan Feb 14 '14 at 11:01

0 Answers0