I'm recently been exploring node.js and I'm still confused of why require works one way and not the other.
Version of node: 0.12.5
Goal: format date time using strftime package
What works:
var strftime = require('strftime');
function time(){
var d = new Date();
return strftime('%Y-%m-%d: %H:%M', d);
}
What does not work:
var strftime = require('strftime');
function time(){
var d = new Date();
d.strftime('%Y-%m-%d: %H:%M');
}
Throws and error stating that strftime is undefined.Can someone explain why? strftime API shows that the second method is a valid example.