Trim text in Velo code

How to trim or substring a text?

Use str.trim() to trim off the white spaces from both sides.
Use str.substring(3,8);// (start,end) to extract part of the string.

Thanks. How about substring?

The substring is not working

It is working. You probably did something wrong. Post your code.

This is the one I wanted to substring. it returns the timestamp and I want to remove the time and keep the date. Thanks
$w ( “#datePicker1” ). value

$w ( “#datePicker1” ). value returns a Date object, not a string

There might be a simpler way, but I can’t remember it off the top of my head, but this should at least work

let fullDate = $w ( “#datePicker1” ). value //Returns a date, not a string
let onlyDate = fulldate.getDate() + “.” + fulldate.getMonth() + “.” + fulldate.getFullYear()

console.log(onlyDate) //06.04.2022 if today is picked

@simen

let onlyDate = fulldate.toLocaleDateString()