1.0.1 • Published 6 years ago
@kev_nz/daylight v1.0.1
daylight
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 28thformat 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