Difference between revisions of "Manuals/calci/MOMENT"

From ZCubes Wiki
Jump to navigation Jump to search
Line 11: Line 11:
 
{| class="wikitable"
 
{| class="wikitable"
 
|+
 
|+
| Format Dates
+
|Format Dates
 
|-
 
|-
 
| '''Function'''  || '''Description'''  
 
| '''Function'''  || '''Description'''  
Line 30: Line 30:
 
|- Relative Time
 
|- Relative Time
 
|-
 
|-
| Function  || Description
+
| '''Function''' || '''Description'''
 
|-
 
|-
 
| moment("20111031", "YYYYMMDD").fromNow() || 8 years ago
 
| moment("20111031", "YYYYMMDD").fromNow() || 8 years ago
Line 47: Line 47:
 
|- Calendar Time
 
|- Calendar Time
 
|-
 
|-
| Function  || Description
+
| '''Function''' || '''Description'''
 
|-
 
|-
 
|moment().subtract(10, 'days').calendar() || Subtract 10 days from today
 
|moment().subtract(10, 'days').calendar() || Subtract 10 days from today
Line 70: Line 70:
 
|- Multiple Local Support
 
|- Multiple Local Support
 
|-
 
|-
| Function  || Description
+
| '''Function''' || '''Description'''
 
|-
 
|-
 
| moment.locale() || en
 
| moment.locale() || en
Line 78: Line 78:
 
| moment().format('LTS') || Current Time with hour, minute and second
 
| moment().format('LTS') || Current Time with hour, minute and second
 
|-
 
|-
|
+
| moment().format('L') || Current Date in format 02/17/2020
 +
|-
 +
| moment().format('l') || Current Date in format 2/17/2020
 +
|-
 +
| moment().format('LL') || Current date in format February 17, 2020
 +
|-
 +
| moment().format('ll') || Current date in format Feb 17, 2020
 +
|-
 +
| moment().format('LLL') || Current date and time in format February 17, 2020 2:04 PM
 +
|-
 +
| moment().format('lll') || Current date and time in format Feb 17, 2020 2:05 PM
 +
|-
 +
| moment().format('LLLL') || Current date and time in format Monday, February 17, 2020 2:06 PM
 +
|-
 +
| moment().format('llll') || Current date and time in format Mon, Feb 17, 2020 2:06 PM
 +
|}
  
 
==Examples==
 
==Examples==

Revision as of 03:37, 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
moment().format('L') Current Date in format 02/17/2020
moment().format('l') Current Date in format 2/17/2020
moment().format('LL') Current date in format February 17, 2020
moment().format('ll') Current date in format Feb 17, 2020
moment().format('LLL') Current date and time in format February 17, 2020 2:04 PM
moment().format('lll') Current date and time in format Feb 17, 2020 2:05 PM
moment().format('LLLL') Current date and time in format Monday, February 17, 2020 2:06 PM
moment().format('llll') Current date and time in format Mon, Feb 17, 2020 2:06 PM

Examples

  1. MOMENT() = "2018-05-24T18:54:09.484Z"
  2. MOMENT().subtract(23,"days") = "2018-05-01T18:54:54.421Z"
  3. MOMENT().subtract(INTERVAL(24,"days")) = "2018-04-30T18:55:33.409Z"


Related Videos

Moment

See Also

References