Moment JS Cheat Sheet by nothingspare via cheatography.com/20576/cs/4731/ Loading || Installing Formatting (cont) html <script type="te xt/ jav asc rip t" Day of Week d [0+], dd [Su+], ddd [Sun+], dddd [Sunday+] src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/momen Hour 24h-Clock H [0+], HH [00+] t.min .js "></ scr ipt > Hour 12h-clock h [1+], hh [01+] cdn https:/ /cd njs .cl oud fla re.com /aj ax/ lib s/m ome nt.js/ 2.10 .6/ mo men t.mi n. Minute m [00+], mm [00+] js Second s [0+], ss [00+] npm npm install moment Second, Fractional S [0-9], SS [00-99] bower bower install moment Zone Z [-00:00], ZZ [-0000] git https:/ /gi thu b.co m/ mom ent /mo men t.git Unix Timestamp X [012345 6789] WWW http:// mom ent js.com/ Unix Millise cond x [012345 678 9012] Parsing master these: Y, M, D, H, m, s, Z, X Now moment() Manipul ate, Constrain, or Validate String moment( "197 7-0 9-0 5", "Y YYY -MM -DD ") Unix moment.uni x(0 123 456 789) Get Start of Period .startO f(S tring) ['week'] Object moment( {year: 1977[, month, day, hour, minute, second]}) Get End of Period .endOf( Str ing) ['week'] Array moment( [year, month, day, hour, minute, second, ms]) $DateA Is Before $DateB .isBefo re( Str ing[, String]) ["197 7-0 9-0 5", "y ear "] Get/Set $DateA Is After$D ateB .isAfte r(S tri ng[, String]) ["197 7-0 9-0 5", "y ear "] Second .second() / .second (/* 0- 59*/) $DateA Is the Same as .isSame (St ring[, String]) ["197 7-0 9-0 5", Minute .minute() / .minute (/* 0- 59*/) $DateB "y ear "] Hour .hour() / .hour(/ *0 -23 */) $DateA Is Between $DateB .isBetw ee( Str ing, String[, String]) Day of Week .day() / .day(/* 0- 6*/) Add Time to Date .add(Nu mber, String) [4, 'days'] Day of Month .date() / .date(/ *1 -31 */) Subtract Time from Date .subtra ct( Num ber, String) [4, 'days'] Day of Year .dayOfY ear() / .dayOfY ear .da y(/ *0 -36 6*/) Constrain Max .max(Ob ject) [moment ().add(1, 'day')] Week of Year .week() / week(/* 1- 53*/) Constrain Min .min(Ob ject) [moment ().sub tra ct(1, 'day')] Month .month() / .month( /*Jan || 1*/) Format to String .format (St ring) ["YY- MM- DD" ] Year .year() / .year(/ *# ### */) Check Validity momentO bje ct.isV alid() Zones Convert to UTC moment( ).ut c() Get UTC Offset moment( ).ut cO ffs et() Set UTC Offset .utcOff set (Nu mber) Formatting Datetime .format ("YY YY- MM-DD HH:mm:s sZ" ) Year YY [15], YYYY [2015] Month Numeric M [1+], MM [01+] Month Alpha MMM [Jan+], MMMM [January+] Day of Month D [1+], Do [1st+], DD [01+] Day of Year DDD [1+], DDDo [1st+], DDDD [001+] By nothingspare Published 4th August, 2015. Sponsored by CrosswordCheats.com cheatography.com/nothingspare/ Last updated 4th August, 2015. Learn to solve cryptic crosswords! Page 1 of 1. http://crosswordcheats.com.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages1 Page
-
File Size-