javascript - Date.now() returns wrong date -
i have mongoose schema
const postschema= new schema({ body:{ type: string, required:true, validate:bodyvalidators}, createdby: { type: string}, to: {type:string, default:null }, createdat: { type:date, default:date.now()}, likes: { type:number,default:0}, likedby: { type:array}, dislikes: { type:number, default:0}, dislikedby: { type:array}, comments: [ { comment: { type: string, validate: commentvalidators}, commentator: { type: string} } ]
});
every posts on app returns aug 20, 2017 @ 10:01 pm it's 2 hours more. here's html, i'm using angular4.
{{post.createdat | date: 'mmm dd, yyyy'}} @ {{post.createdat | date:'shorttime'}}
i can't understand why
mongoose receiving value calculate @ time start it, instead of function. should pass function instead of running it. whenever use parenthesis executing function instead of referencing it. had same problem once.
Comments
Post a Comment