Return begin date of current week

Hi,

Maybe I did not find the function for this yet, but how would one get always the begin date of the current week?

Regards,
Nick

Don’t think that can be done directly but you could simple add a JS function to the page and call it. Lots of examples on the net using JS or Moments
This seems a popular one (not tested)

function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6 : 1);
return new Date(d.setDate(diff));
}

Maybe there is a way of replicating this in Wappler but don’t have time to try - sorry

You can do it with PHP quite easily:

<?php echo date("Y-m-d", strtotime('monday this week')), "\n"; ?>

The above, assuming Monday is the start of your week, should display:

2019-05-20

2 Likes

thanks you, @Dave. works like charm.

1 Like