Date operations (No API)

I made a simple JavaScript code to get the date after certain number of days.
image
This is giving today’s date but if I add some days I get the future date in the label.
image

All managed by a web viewer extension running .html file added to the project as an asset…

The Google sheet solution is still a viable solution and it works just as good.

This is the blocks of the project

This is the JavaScript Code

<!DOCTYPE html>
<html>
<head>
<script src="https://thunkable.github.io/webviewer-extension/thunkableWebviewerExtension.js" type="text/javascript"></script>
</head>

<script>
  ThunkableWebviewerExtension.receiveMessage(function(message) {
    const dateObj = JSON.parse(message);
    const myDate = new Date(dateObj[0], dateObj[1] - 1, dateObj[2]);
    myDate.setDate(myDate.getDate() + dateObj[3]);
    ThunkableWebviewerExtension.postMessage(myDate.toUTCString());
});
</script>
</html>
2 Likes