@riversun/simple-date-format
v1.1.8
Published
Simple Date Formater for JavaScript.It allows for formatting (date -> text) like with "yyyyMMdd HHmmss SSS" , "yyyyMd Hms"
Downloads
708
Readme
simple-date-format
Simple Date Formater for JavaScript. It allows for formatting date → text .
You can easily format date with specific patterns like as follows.
yyyyMMdd'T'HHmmssXX
→ 20180717T120856+0900
install
use node.js/npm
install module
npm install @riversun/simple-date-format
import module
import SimpleDateFormat from "@riversun/simple-date-format";
or
require module
const SimpleDateFormat = require('@riversun/simple-date-format');
use with <script>tag from CDN
<script src="https://cdn.jsdelivr.net/npm/@riversun/simple-date-format/lib/simple-date-format.js"></script>
usage
const date = new Date('2018/07/17 12:08:56');
const sdf = new SimpleDateFormat();
console.log(sdf.formatWith("yyyy-MM-dd'T'HH:mm:ssXXX", date));//to be "2018-07-17T12:08:56+09:00"
const date = new Date('2018/07/17 12:08:56');
const sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
console.log(sdf.format(date));//to be "2018-07-17T12:08:56+09:00"
Pattern of the date
The following examples show how date and time patterns are interpreted. The given date and time are 2018-07-17 12:08:56 local time in Tokyo/Japan time zone.