Format Date

Post Reply
administrator
Site Admin
Posts: 82
Joined: Mon Dec 03, 2018 10:35 am

Format Date

Post by administrator » Tue Jan 30, 2024 11:02 am

To format a date from "1/17/2024" to "17-01-2024" in JavaScript, you can use the following script:

Code: Select all

// Assuming your data field is named 'Datum'
var datum = Field("Datum");

// Check if the 'Datum' field is not empty
if (datum) {
    // Split the date into parts
    var dateParts = datum.split('/');

    // Reformat the date as 'DD-MM-YYYY'
    var formattedDate = dateParts[1] + '-' + dateParts[0] + '-' + dateParts[2];

    // Set the modified value back to the 'Datum' field
    Datum = formattedDate;
}

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests