Today I Learned
  • Introduction
  • Problem Solving
    • leetcode
      • 1. Two Sum
        • CPP
        • Java
        • JavaScript
        • Kotlin
        • Python
    • contest
      • google code jam
  • developer
    • ansible
    • python
      • line_by_line
      • config
        • yaml
        • configparser
  • linux
    • cut
  • Programming Languages
    • javascript
      • array
      • base64
      • canvas
      • date
        • moment.js
      • jquery
      • json
      • jsplumb
      • konva
      • nodejs
      • react
      • string
    • kotlin
      • 2 코틀린 기초.md
  • spring framework
    • spring boot
  • game
    • ingress
    • Rockman
      • Rockman X 1
      • Rockman X 2
      • Rockman X 3
  • database
    • mysql
  • me
    • resume
      • experience
      • extracurricular_activities
Powered by GitBook
On this page
  • cdn 사용
  • YYYYMMDD
  • yesterday
  • add days
  • a week ago
  • specific date

Was this helpful?

  1. Programming Languages
  2. javascript
  3. date

moment.js

PreviousdateNextjquery

Last updated 5 years ago

Was this helpful?

cdn 사용

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

YYYYMMDD

$("#date").val(moment(new Date()).format("YYYYMMDD"));

yesterday

moment().subtract(1, 'day')

add days

var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');

a week ago

moment().subtract(7, 'day')

specific date

  • 1985.05.20

    moment().year(1985).month(5-1).date(20)
Moment.js
cdn
momentJS date string add 5 days