JavaScript toUTCString() method

The JavaScript date toUTCString() method is used to get the particular date in the form of a string using the UTC time zone. Syntax: dateObj.toUTCString(); Return: String representation of date portion of a Date object UTC time zone. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toUTCString()); </script> </body> </html>

JavaScript toTimeString() method

The JavaScript date toTimeString() method is used to get the time portion of a Date object. Syntax: dateObj.toTimeString(); Return: String representation of the time portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toTimeString()); </script> </body> </html>

JavaScript toString() method

The JavaScript date toString() method is used to get the date in the form of a string. Syntax: dateObj.toString(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toString()); </script> </body> </html>

JavaScript toJSON()

The JavaScript date toJSON() method is used to get a string representing the Date object and serializing the Date object at the time of JSON serialization. Syntax: dateObj.toJSON(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toJSON()); </script> </body> </html>

JavaScript toISOString()

The JavaScript date toISOString() method is used to get the date in the form ISO format string. Syntax: dateObj.toISOString(); Return: ISO format string representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toISOString()); </script> </body> </html>

JavaScript toDateString()

The JavaScript date toDateString() method is used to get the date portion of a Date object. Syntax: dateObj.toDateString(); Return: String representation of the date portion of a Date object. Example: <!DOCTYPE html> <html> <body> <script> var bday=new Date(“November 16, 1994 21:10:10”); document.writeln(bday.toDateString()); </script> </body> </html>

JavaScript setUTCSeconds()

The JavaScript date setUTCSeconds() method sets the second value for the particular date on the basis of universal time. Syntax: dateObj.setUTCSeconds(new_seconds); Parameters: new_seconds: Integer value between 0 to 59. Example: <!DOCTYPE html> <html> <body> <script> var today =new Date(); document.writeln(today.getUTCSeconds()+”<br>”); today.setUTCSeconds(40); document.writeln(today.getUTCSeconds()); </script> </body> </html>

JavaScript setUTCMonth()

The JavaScript date setUTCMonth() method sets the month value for the particular date on the basis of universal time. Syntax: dateObj.setUTCMonth(new_month); Parameters: new_Date: Integer value between 0 to 11. Example: <!DOCTYPE html> <html> <body> <script> var today =new Date(); document.writeln(today.getUTCMonth()+”<br>”); today.setUTCMonth(4); document.writeln(today.getUTCMonth()); </script> </body> </html>

JavaScript setUTCMinutes()

The JavaScript date setUTCMinutes() method sets the minute value for a particular date on the basis of universal time. Syntax: dateObj.setUTCMinutes(new_minutes); Parameters: new_minutes: Integer value between 0 to 59. Example: <!DOCTYPE html> <html> <body> <script> var today =new Date(); document.writeln(today.getUTCMinutes()+”<br>”); today.setUTCMinutes(45); document.writeln(today.getUTCMinutes()); </script> </body> </html>

JavaScript setUTCMilliseconds()

The JavaScript date setUTCMilliseconds() method sets the millisecond value for the particular date on the basis of universal time. Syntax: dateObj.setUTCMilliseconds(new_milliseconds); Parameters: new_milliseconds: Integer value between 0 to 999. If its value is greater than 999 then the second value will increase accordingly. Example: <!DOCTYPE html> <html> <body> <script> var today =new Date(); document.writeln(today.getUTCMilliseconds()+”<br>”); today.setUTCMilliseconds(500); … Read more