Glide Date and Glide DateTIme
What is Glide Date and Usage
Glide Date classes
will provides methods for performing
operations on Glide Date objects, such as instantiating Glide Date objects or
working with Glide Date fields.
·
These methods are used to work with date fields on form
·
Glide Date global oject is GlideDate
Glide Date
Methods
Glide
Date |
|
glideDate() |
getMonthNoTZ() |
getByFormat() |
getValue() |
getDayOfMonthNoTZ() |
getYearNoTZ() |
getDisplayValue() |
setDisplayValue() |
getDispalyValueInternal() |
setValue() |
|
Subtract() |
Practice with these all methods |
Glide Date Exercises
1.
Navigate to System
Definition
2.
Open Scripts –
Background Application
3.
Write code into given space
1. Working
with GlideDate () method
Creates a GlideDate object with the current date time.
var date = new GlideDate();
gs.print (date);
2. Working
with getByFormat () method
This method is used to gets
the date in the specified date format.
var date = new GlideDate
();
gs.print (date.getByFormat
('dd-MM-yyyy'));
3. Working
with getDayOfMonthNoTZ() method
Gets the day of the month stored by the GlideDate object, expressed in
the UTC time zone.
var glideDate =new GlideDate();
gs.print (glideDate.getDayOfMonthNoTZ());
4. Working
with getDayOfMonthNoTZ() method
This method is used to gets
the date in the current logged in user's display format and time zone.
var glideDate =new GlideDate ();
gs.print(glideDate.getDisplayValue());
5. Working
with getDisplayValueInternal()
method
Gets the display value in the internal format (yyyy-MM-dd).
var glideDate
=new GlideDate();
gs.print (glideDate.getDisplayValueInternal());
6. Working
with getMonthNoTZ() method
Gets the month stored by the GlideDate object, expressed in the UTC time
zone.
var glideDate =new GlideDate();
gs.print (glideDate.getMonthNoTZ());
7. Working
with getValue () method
Gets the date value stored in the
database by the GlideDate object in the internal format, yyyy-MM-dd, and the system time zone, UTC by default.
var glideDate =new
GlideDate();
gs.print (glideDate.getValue());
8. Working
with getYearNoTZ () method
Gets the year stored by the GlideDate
object, expressed in the UTC time zone.
var glideDate =new
GlideDate();
gs.print
(glideDate.getYearNoTZ());
9. Working
with setDisplayValue () method
Sets a date value using the current user's display format and time zone.
var glideDate
=new GlideDate();
glideDate.setDiaplayValue(18-04-2020);
gs.print
(glideDate.getValue());
10. Working
with setValue () method
Sets the date of the GlideDate object.
var glideDate
=new GlideDate();
glideDate.setValue('2020-04-18');
gs.print
(glideDate.getValue());
11. Working
with subtract () method
Gets the duration difference between two GlideDate values.
Code
var firstDate = new
GlideDate();
firstDate.setDisplayValue('2020-01-25');
var secondDate = new
GlideDate();
secondDate.setDisplayValue('2020-01-29');
difference=
GlideDate.subtract(firstDate, secondDate);
gs.info(difference.getDisplayValue());
Comments
Post a Comment