Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/binocarlos/date-floor

Like Math.floor but for Date objects
https://github.com/binocarlos/date-floor

Last synced: 10 days ago
JSON representation

Like Math.floor but for Date objects

Awesome Lists containing this project

README

        

date-floor
==========

![Build status](https://api.travis-ci.org/binocarlos/date-floor.png)

Like Math.floor but for Date objects

## installation

```
$ npm install date-floor
```

## usage

Take a date any get back one that is the closest preceding:

* year
* month
* day
* hour
* minute

```js
var datefloor = require('date-floor');

var d = new Date('05/06/2014 11:56:45');

// 01/01/2014 00:00:00
var year = datefloor(d, 'year');

// 05/01/2014 00:00:00
var month = datefloor(d, 'month');

// 05/06/2014 00:00:00
var day = datefloor(d, 'day');

// 05/06/2014 11:00:00
var hour = datefloor(d, 'hour');

// 05/06/2014 11:56:00
var minute = datefloor(d, 'minute');
```

## license

MIT