问题
How can I get the time range for yesterday from midnight until midnight:
Example:
Yesterday 22.07.2015
Result:
22.07.2015 00:00:00 (AM)
22.07.2015 23:59:59 (PM)
Date format doesn't matter this is just an example.
回答1:
moment().subtract(1,'days').startOf('day').toString()
"Thu Jul 30 2015 00:00:00 GMT-0600"
moment().subtract(1,'days').endOf('day').toString()
"Thu Jul 30 2015 23:59:59 GMT-0600"
来源:https://stackoverflow.com/questions/31593445/moment-js-get-yesterday-time-range-from-midnight-to-midnight