1.1.6 • Published 6 years ago
datetimes v1.1.6
Extend class of Date
Install
npm install datetimes --save
Usage
nodejs - basic usage
'use strict'
const Datetimes = require('datetimes');
var date = new Datetimes();
console.log(date);
//result:
// Tue Apr 03 2018 10:34:41 GMT-0300 (Hora oficial do Brasil) {}
Browser - basic usage
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="data"></div>
</body>
<script src="dist/datetimes.min.js"></script>
<script>
var div = document.getElementById('data');
div.innerText = new Datetimes().format('dddd, dd de MMMM de yyyy');
</script>
</html>
Functions
format(stringFormat, options): string
var date = new Datetime(2017, 2, 22); date.format("dd/MM/yyyy"); // 22/03/2017 var date2 = new Datetime(2017, 2, 22); date2.format("dddd dd MMMM yyyy", { language: 'enUS' }); // wednesday 22 march 2017
- stringFormats: - year - 01/01/2017 - yyyy => 2017 - 01/01/2017 - yyy => 017 - 01/01/2017 - yy => 17 - month - 01/01/2017 - MMMM => janeiro - 01/01/2017 - MMM => jan - 01/01/2017 - MM => 01 - 01/01/2017 - M => 1 - day: - 01/01/2017 - dddd => domingo - 01/01/2017 - ddd => dom - 01/01/2017 - dd => 01 - 01/01/2017 - d => 1 - hour: - 13:30:07 - HH => 13 - 13:30:07 - h => 3 - minute: - 13:05:07 - mm => 05 - second: - 13:05:07 - ss => 07 - millisecond: - 13:05:07:123 - zzz => 123
- options: possibles values "pt-BR", "es-MX" or "en-US"
now(): Datetimes
var date = new Datetime();
date.now() // datetime => date time actual
- noTimeZone(): Datetimes
var Datetime = new Datetime();
Datetime.noTimeZone(2017, 2, 22) // Will return the date 22/03/2017 without time zone