VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-date-compile-api/

⇱ Node.js Date.compile() API - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js Date.compile() API

Last Updated : 27 Jan, 2023

The date-and-time.Date.compile() is a minimalist collection of functions for manipulating JS date and time module which is used to compile a format string for the parser.

Required Module: Install the module by npm or used it locally.

  • By using npm.
npm install date-and-time --save
  • By using CDN link.
<script src="/path/to/date-and-time.min.js"></script>

Syntax:

compile(formatString)

Parameters: This method takes the format string as the parameter.

Return Value: This method returns the formatted string date.

Example 1:

Run the index.js file using the following command:

node index.js

Output:

Formatted date and time : 1/1/1970

Example 2:

Run the index.js file using the following command:

node index.js

Output:

Formatted date and time: 
Sat Jul 03 2021 00:00:00 GMT+0530 (India Standard Time)

Reference: https://github.com/knowledgecode/date-and-time

Comment

Explore