How to show in php only current weekday.After passing of current week only then next weekdays show -
i have code.that showing 5 business days(that correct). want current weekdays passed. after passing of current week next weekdays shows
<?php for($i=0;$i<=4;$i++): ?> <label ><?php echo date('d-m-y', strtotime("+$i weekday")); ?></label> <label ><?php echo date('l',strtotime("+$i weekday")); ?></label><br> <?php endfor; ?>
its output is:
19-nov-2014 wednesday
20-nov-2014 thursday
21-nov-2014 friday
24-nov-2014 monday
25-nov-2014 tuesday
this showing next week days.
want this:
17-nov-2014 monday
18-nov-2014 tuesday
19-nov-2014 wednesday
20-nov-2014 thursday
21-nov-2014 friday
try this:
$monday_this_week = date("y-m-d",strtotime('monday week')); <?php for($i=0;$i<=4;$i++): ?> <?php $date = date('d-m-y', strtotime("+$i days", strtotime($monday_this_week))); ?> <label ><?php echo $date; ?></label> <label ><?php echo date('l', strtotime($date)); ?></label><br> <?php endfor; ?>
Comments
Post a Comment