When you code maybe you find difficult to get the week number from a date. Maybe you think of some particular dates and how will you get an algorithm ready for this?

Do not worry! In PHP this function is already done. Here is how to get the week number from a date:

function weeknumber($date){
  $day = new DateTime($date);
  return $day->format("W");
}

 

 

You might find interesting:   How to programmatically create a Woocommerce coupon

LEAVE A REPLY

Please enter your comment!
Please enter your name here