Date not updating automatically

Date not updating automatically

Im not able to call use the code below to update the field as shown in the picture, im not sure whether i did something wrong but the outcome i want is the date to show up for example as: Oct 24 2024


var date = new Date();
var formattedDate = date.toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });

= ZDK.Page.getField('Date');
w.setValue(formattedDate);