Socket
Socket
Sign inDemoInstall

handlebars-dateformat

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    handlebars-dateformat

handlebars date format helper


Version published
Weekly downloads
2.6K
decreased by-21.15%
Maintainers
1
Install size
4.15 MB
Created
Weekly downloads
 

Readme

Source

handlebars-dateformat

handlebars date format helper.

Installation

npm install --save handlebars-dateformat

Usage

Register the Helper

handlebars.registerHelper('dateFormat', require('handlebars-dateformat'));

Call the helper from a template

{{dateFormat date format utc}}

Parameters:

  • date is a JavaScript Date or an instance of moment.
  • format is a string containing the desired format (can be a variable or a literal). Placeholders are defined in the moment.js docs.
  • utc optional boolean (true or false) to decide whether or not to convert the date to UTC before formatting. Defaults to false.

Example

app.js:

"use strict";

var hbs = require('hbs');
var express = require('express');

hbs.registerHelper('dateFormat', require('handlebars-dateformat'));

var app = express();

app.set('view engine', 'hbs');    

app.get('/', function (req, res) {
    res.render('index', { now: new Date() });
});

app.listen(3000);

views/index.hbs:

The server time is: {{dateFormat now "dddd, MMMM Do YYYY, h:mm:ss a"}}

Testing

npm test

License

See LICENSE.md

Keywords

FAQs

Last updated on 30 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc