Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  150] [ 3]  / answers: 1 / hits: 100681  / 7 Years ago, sat, june 17, 2017, 12:00:00

I am working with moment.js, but as I am testing the moment.js library I continue to receive an error.



var back30Days=moment().subtract(30, 'days').format(dddd, MMMM Do YYYY, h:mm:ss p);


it returns moment not defined. referring to .format(dddd, MMMM Do YYYY, h:mm:ss p);



I've read the documentation, and everything looks fine, but when I reload my page, the js I'm working with won't load.



any tips would be greatly appreciated!


More From » time

 Answers
19

With latest momentjs:



<script src=https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js></script>




var back30Days=moment().subtract(30, 'days').format(dddd, MMMM Do YYYY, h:mm:ss p);

console.log('back30Days --> ' + back30Days);

<script src=https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js></script>




[#57408] Thursday, June 15, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nestorjarettg

Total Points: 451
Total Questions: 108
Total Answers: 108

Location: Rwanda
Member since Thu, Feb 10, 2022
2 Years ago
;