简体   繁体   中英

How do I resolve the syntax error when using toDateString method of Javascript?

I am using Robot Framework and need to remove the time from a date. I use Get Current Date (exclude milliseconds) and pass value to a variable. The goal is to strip the time from the date. I have a syntax error which I cannot resolve.

${date}=  Get Current Date  exclude_millis=true

Execute Javascript  Date.toDateString(${date})

Error: JavascriptException: Message: javascript error: missing ) after argument list

The toDateString() method returns the date portion of a Date object as a human-readable string.

Syntax:

dateObj.toDateString();

Parameters:

This method does not take any parameters.

Return value:

A string representing the date portion of the given Date object.

Example:

var d = new Date();

console.log(d.toDateString());

Output:

"Wed Apr 12 2017"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM