0.2.3 • Published 9 years ago

daylight v0.2.3

Weekly downloads
29
License
MIT
Repository
github
Last release
9 years ago

daylight

Build Status

I absolutely love the moment.js library, but at times it runs a bit heavier than I really need. I like the simplicity of PHP's built-in date() function and wrote this to be sort of similar.

usage

note: daylight does a rather rudimentary job parsing dates (strings are just passed through Date.parse()), so beware of local timezone vs utc time-string pitfalls.

in the browser

TODO: requirejs, commonjs, etc. module support

<script src="daylight.js"></script>
<script>
    var today = daylight('l, F jS', Date.now());
    var p = document.createElement('p');
    p.innerText = today;
    document.body.appendChild(p);

    //=> <p>Wednesday, May 28th</p>
</script>

using node

install with npm install daylight, run tests with npm test, etc.

var daylight = require('daylight');
console.log(daylight('l, F jS', Date.now()));

//=> Wednesday, May 28th

format strings

these are copied from php's date() function

characters not on this list are passed normally; to escape characters you'll have to use double backslashes:

var today = daylight('\\d\\a\\y: l', Date.now());
console.log(today);
//=> day: Wednesday
0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago