npm.io
0.0.32 • Published 11 years ago

eden-time

Licence
Version
0.0.32
Deps
1
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

#Time

DESCRIPTION

Build Status

General

Installation

npm install eden-time
Usage
var time = require('eden-time');

Methods


now
 number now(now.getTime());

Returns Unix time

Parameters
  1. now.getTime() - function (to get time by milliseconds)
Returns

number

Example
Code
<!-- time().now(); -->

now.getTime();
Outputs
1418634952879
<!-- not fixed, changing every now and then since it counts milliseconds-->

toDate
 string toDate(1410535142494, 'M d', time().offset);

Converts time to a readable formatted date

Parameters
  1. 1410535142494 - date (by milliseconds)

  2. 'M d' - format of date(m-month, d-day, y-year)

  3. time().offset - gmt (am | pm)

Returns

string

Example
Code
time().toDate(1410535142494 + time().offset, 'M d');
time().toDate(1410535142494 + time().offset, 'F d, Y');
time().toDate(1410535142494 + time().offset, 'Y-m-d H:i:s');
time().toDate(1410535142494 + time().offset)));
Outputs
'Sep 12'
'September 12, 2014'
'2014-09-12 15:19:02'
'September 12, 2014 03:19pm'

toRelative
 string toRelative(time().now() - 1000);

Converts time to a relative formatted date

Parameters
  1. time().now() - 1000 - int|string|Date (time before, now, or after)
Returns

string

Example
Code
time().toRelative(time().now() - 1000);
time().toRelative(time().now() - (1000 * 10));
time().toRelative(time().now() - (1000 * 60));
time().toRelative(time().now() - (1000 * 60 * 60 * 2));
time().toRelative(time().now() - (1000 * 60 * 60 * 24));
time().toRelative(time().now() - (1000 * 60 * 60 * 48));
time().toRelative(time().now() - (1000 * 60 * 60 * 24 * 14));

time().toRelative(time().now() + 1000);
time().toRelative(time().now() + (1000 * 10.1));
time().toRelative(time().now() + (1000 * 60 * 1.5));
time().toRelative(time().now() + (1000 * 60 * 60 * 2.5));
time().toRelative(time().now() + (1000 * 60 * 60 * 24.5));
time().toRelative(time().now() + (1000 * 60 * 60 * 48));
time().toRelative(time().now() + (1000 * 60 * 60 * 24 * 14.1));
Outputs
'Now'
'10 seconds ago'
'1 minute ago'
'2 hours ago'
'Yesterday'
'2 days ago'
'2 weeks ago'

'Now'
'in 10 seconds'
'in 1 minute'
'in 2 hours'
'Tomorrow'
'in 2 days'
'in 2 weeks'

Keywords