Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

JavaScript setUTCDate

by suresh

JavaScript setUTCDate function is used to set Day of a Month in a given date as per the universal time. The syntax of the JavaScript setUTCDate Date function is:

 Date.setUTCDate(Day_Number)

JavaScript setUTCDate Function Example

We are using this setUTCDate function to set the current day to 30th as per the universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Date Functions </title>
</head>
<body>
    <h1> JavaScript setUTCDate Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCDate (30);
  document.write("After setUTCDate () : " + dt);
</script>
</body>
</html>

OUTPUT

JavaScript SetUTCDate Function 1

JavaScript set UTC Date Function Example 2

In this setUTCDate example, we set the day of a custom date to 31 according to universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Date Functions </title>
</head>
<body>
    <h1> JavaScript setUTCDate Function Example </h1>
<script>
  var dt = Date("January 1, 2017 10:11:19");
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCDate (31);
  document.write("After setUTCDate () : " + dt);
</script>
</body>
</html>

OUTPUT

JavaScript SetUTCDate Function 2

If we set the Month number more than 31, then setUTCDate will go to the next month

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Date Functions </title>
</head>
<body>
    <h1> JavaScript setUTCDate Function Example </h1>
<script>
  var dt = Date("January 1, 2017 10:11:19");
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCDate (35);
  document.write("After setUTCDate () : " + dt);
</script>
</body>
</html>

OUTPUT

JavaScript SetUTCDate Function 3

Placed Under: JavaScript

Trending Posts

Table Partitioning in SQL Server

Informatica Mapping

MySQL TIME_TO_SEC Function

MySQL CONVERT_TZ Function

Linear Gauges in SSRS

C Program to find Last Occurrence of a Character in a String

MDX Head Function

JavaScript ACOSH

SQL FOR XML RAW

SQL STRING_AGG Function

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy