Difference between revisions of "Manuals/calci/MOMENT"
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ | ||
− | | | + | | Format Dates |
|- | |- | ||
| '''Function''' || '''Description''' | | '''Function''' || '''Description''' |
Revision as of 02:27, 17 February 2020
MOMENT()
Description
- This function shows the current date and time.
- MOMENT is used to display the present date and time in Greenwich mean time which is called GMT time.
- UK time is GMT only during the winter months.
- MOMENT() gives the current date and time, also converts the current date and time to the specified format.
- Here it formats a date as a four digit year, followed by a space, followed by a two digit month, another space, and a two digit date.
- Using MOMENT(),we can do multiple items.
Format Dates | |
Function | Description |
moment().format('MMMM Do YYYY, h:mm:ss a') | Shows current date and time |
moment().format('dddd'); | Shows the current day |
moment().format("MMM Do YY") | Shows current month and Year |
moment().format('YYYY [escaped] YYYY') | Current Year |
moment().format() | shows yyyy,mm,dd and time format |
Function | Description |
moment("20111031", "YYYYMMDD").fromNow() | 8 years ago |
moment("20120620", "YYYYMMDD").fromNow() | 8 years ago |
moment().startOf('day').fromNow() | 13 years ago |
moment().endOf('day').fromNow() | in 11 hours |
moment().startOf('hour').fromNow() | 23 minutes ago |
Function | Description |
moment().subtract(10, 'days').calendar() | Subtract 10 days from today |
moment().subtract(6, 'days').calendar() | Subtract 6 days from today |
moment().subtract(3, 'days').calendar() | Subtract 3 days from today |
moment().subtract(1, 'days').calendar() | Subtract 1 day from today |
moment().calendar(); | Today current time |
moment().add(1, 'days').calendar() | Add 1 day from today |
moment().add(3, 'days').calendar() | Add 3 days from today |
moment().add(10, 'days').calendar() | Add 10 days from today |
Function | Description |
moment.locale() | en |
moment().format('LT') | Current Time with hour and Minute |
moment().format('LTS') | Current Time with hour, minute and second |
Examples
Related VideosSee AlsoReferences |