ESP32 Javascript display date not working

Hello

Can anyone help with this query. I have a ESP32 web server and an option to display and change the date using JS
(My time portion is working correctly - only the date does not work/display)

JS(javascript) that I call for updating the date values in the web page :

server.on("/displaydate", {
String s = "";
s+="$('date').value=('0' +"+ (String)MyDateDay + ").slice(-2)+'/'+ ('0' +" + (String)MyDateMonth + ").slice(-2)+'/'+ ('0' +" + (String)MyDateYear + ").slice(-2);";
....................................}

Single line of html (out of the web page) to display the date in a small box :

Any help appreciated

Thanks

C

any

</script>

in the code we don't see?

if you save

<p>Date/Time: <span id="datetime"></span></p>

<script>
var dt = new Date();
document.getElementById("datetime").innerHTML = (("0"+(dt.getMonth()+1)).slice(-2)) +"/"+ (("0"+dt.getDate()).slice(-2)) +"/"+ (dt.getFullYear()) +" "+ (("0"+dt.getHours()+1).slice(-2)) +":"+ (("0"+dt.getMinutes()+1).slice(-2));
</script>

in a test.htm file and open it in your browser, it will should display the date/time (just mess around with the formula if it does not util you can see what you want)

Thanks for reply - will try.

Any other ideas would be welcome !

I should have been more specific :

I have 3 variables called :
unsigned char MyDateDay;
unsigned char MyDateMonth;
unsigned char MyDateYear;

MyJS(javascript) that I call for updating the date values in the web page :

server.on("/displaydate", {
String s = "";
s+="$('date').value=('0' +"+ (String)MyDateDay + ").slice(-2)+'/'+ ('0' +" + (String)MyDateMonth + ").slice(-2)+'/'+ ('0' +" + (String)MyDateYear + ").slice(-2);";
....................................}

Single line of html (out of the web page) to display the date in a small box :

Try to print on your arduino the s string to see if it’s built the way you expect it