0.0.32 • Published 9 years ago

eden-time v0.0.32

Weekly downloads
79
License
-
Repository
github
Last release
9 years ago

#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'
0.0.32

9 years ago

0.0.31

9 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.12

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.2

10 years ago