A direct approach is to use new Date() :
const dateString = "2012.08.10";
const date = new Date(dateString);
const timestamp = date.getTime() / 1000; // Convert milliseconds to seconds
console.log(timestamp); //
With the Unix timestamp (seconds), you can directly create a Date object from a date string and use getTime() to get the timestamp in milliseconds. Dividing by 1000 converts it to seconds, which is the typical Unix timestamp format.