i have written some code in javascript, and i want to use today's date as my file name, even i tried below code but it wont work for me.
filename=${`any_name_${new Date().toJSON().slice(0,10)}.zip
can anyone help me with it?
You can use template literals to accomplish this:
let filename = `any_name_${(new Date().toJSON().slice(0,10))}.zip`
console.log(`Add here ${filename}`);
You can use string concatenation:
var filename="any_name_" + new Date().toJSON().slice(0,10) + ".zip";
console.log(filename)
Output:
any_name_2019-04-04.zip
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With