---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MobileGlideTime - Scoped

# MobileGlideTime - Scoped {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 7 minutes to read  
The MobileGlideTime API provides the subset of GlideTime available to mobile scripts. It represents the time-of-day portion of a MobileGlideDateTime value.

MobileGlideTime provides the subset of GlideTime that can be evaluated against the local
database on a device. It represents the time-of-day portion of a [MobileGlideDateTime](https://www.servicenow.com/docs/NvYzicw7gURIEMK_3ZMN2A#MobileGlideDateTimeScopedAPI "The MobileGlideDateTime API provides methods for working with date and time values in mobile scripts. Capabilities include comparing two values, formatting a value for display, reading parts of a value like the month or day of the week, and checking time zone and daylight saving time information.") value, for scripts that control behavior based on the time of day and not the calendar date, such as a script that checks whether the current time falls within
business hours.

Whether a script that calls this API is evaluated on the instance or on the device depends on how the component that runs the script is configured. The methods in this class are available in both cases: the mobile client provides its
own implementation of the same API surface, so the same script returns the same result in either context. Typical calling contexts include a condition script on a mobile button (sys_sg_button) and an
execution script on a write-back action item or step.
This API contains the following capabilities:

* Formatting times for display: [MobileGlideTime - getByFormat(String format)](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getByFormat_S "Gets the time of day in a format that you specify, such as HH:mm."), [MobileGlideTime - getDisplayValue()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getDisplayValue "Gets the time of day in the current user's display format.")
* Getting times for storing and comparing: [MobileGlideTime - getValue()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getValue "Gets the time of day in the internal format."), [MobileGlideTime - getDisplayValueInternal()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getDisplayValueInternal "Gets the time of day in the user's time zone, in the internal format.")
* Getting parts of a time: [MobileGlideTime - getHourOfDayLocalTime() / getHourOfDayUTC()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getHourOfDayLocalTime_getHourOfDayUTC "Gets the hour of the time of day on a 24-hour clock, in the user's time zone or in UTC."), [MobileGlideTime - getHourLocalTime() / getHourUTC()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getHourLocalTime_getHourUTC "Gets the hour of the time of day on a 12-hour clock, in the user's time zone or in UTC."), [MobileGlideTime - getMinutesLocalTime() / getMinutesUTC()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getMinutesLocalTime_getMinutesUTC "Gets the minutes of the time of day, in the user's time zone or in UTC."), [MobileGlideTime - getSeconds()](https://www.servicenow.com/docs/fWod8RxgNbYtZYa9b5Y~zg#MGT-getSeconds "Gets the seconds of the time of day.")

For guidance on date time input strings with a list of common format conflicts, refer to [Server-side script use cases](https://www.servicenow.com/docs/T16C7mU7BHGDoHJDPxeUKg#useful-server-side-scripts "Use cases for server-side scripts include logging output, getting user objects, and modifying date/time values.").

## API access {#MobileGlideTimeScopedAPI__section_osk_grp_lkc}

This API is registered in the sn_mobile_scripting application scope and requires the mobile_admin role. It requires the
com.glide.sg.mobile_scripting plugin, which is enabled by default. The class has no public constructor. Obtain an instance from the `getTime()` or `getLocalTime()` method
of [MobileGlideDateTime](https://www.servicenow.com/docs/NvYzicw7gURIEMK_3ZMN2A#MobileGlideDateTimeScopedAPI "The MobileGlideDateTime API provides methods for working with date and time values in mobile scripts. Capabilities include comparing two values, formatting a value for display, reading parts of a value like the month or day of the week, and checking time zone and daylight saving time information.").

## MobileGlideTime - getByFormat(String format) {#ariaid-title2}

Gets the time of day in a format that you specify, such as `HH:mm`.
{#MGT-getByFormat_S__table_MGT-getByFormat_S_p__entry__3}

| Name | Type | Description |
|-|-|-|
| format | String | Time format pattern, such as `HH:mm` or `HH:mm:ss`. |
[Table 1. Parameters]

{#MGT-getByFormat_S__table_MGT-getByFormat_S_p} {#MGT-getByFormat_S__table_MGT-getByFormat_S_r__entry__2}

| Type | Description |
|-|-|
| String | Time of day, formatted according to `format`. |
[Table 2. Returns]

{#MGT-getByFormat_S__table_MGT-getByFormat_S_r}  
This example gets the current local time of day and logs it in `HH:mm` format.

    var time = mgs.nowGlideDateTime().getLocalTime();
            mgs.info(time.getByFormat('HH:mm'));

Output:

    16:44

This example formats the same time two ways. It shows the user a short time in a message and writes the full time to the log, such as to record a check-in.

    var time = mgs.nowGlideDateTime().getLocalTime();
            var shortTime = time.getByFormat('HH:mm');
            var fullTime = time.getByFormat('HH:mm:ss');
            mgs.addInfoMessage('Checked in at ' + shortTime);
            mgs.info('Check-in recorded at ' + fullTime);

Message shown to the user:

    Checked in at 16:44

Output written to the log:

    Check-in recorded at 16:44:17

## MobileGlideTime - getDisplayValue() {#ariaid-title3}

Gets the time of day in the current user's display format.
{#MGT-getDisplayValue__table_MGT-getDisplayValue_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#MGT-getDisplayValue__table_MGT-getDisplayValue_p} {#MGT-getDisplayValue__table_MGT-getDisplayValue_r__entry__2}

| Type | Description |
|-|-|
| String | Time of day in the current user's display format, such as `4:44:17 PM`. |
[Table 4. Returns]

{#MGT-getDisplayValue__table_MGT-getDisplayValue_r}  
This example gets the current local time of day in the user's display format and logs it.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getDisplayValue());

Output:

    4:44:17 PM

This example shows the user the check-in time in their own display format. Use the display value for text that users read. Use getDisplayValueInternal() or getValue() for values that a script compares or stores.

    var time = mgs.nowGlideDateTime().getLocalTime();
            mgs.addInfoMessage('Check-in time: ' + time.getDisplayValue());

Message shown to the user:

    Check-in time: 4:44:17 PM

## MobileGlideTime - getDisplayValueInternal() {#ariaid-title4}

Gets the time of day in the user's time zone, in the internal format.
{#MGT-getDisplayValueInternal__table_MGT-getDisplayValueInternal_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#MGT-getDisplayValueInternal__table_MGT-getDisplayValueInternal_p} {#MGT-getDisplayValueInternal__table_MGT-getDisplayValueInternal_r__entry__2}

| Type | Description |
|-|-|
| String | Time of day in the internal format, `HH:mm:ss`. |
[Table 6. Returns]

{#MGT-getDisplayValueInternal__table_MGT-getDisplayValueInternal_r}  
This example gets the current local time of day in the internal format and logs it.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getDisplayValueInternal());

Output:

    16:44:17

This example compares the current local time with a 5:00 PM cutoff. A button condition can use this check to show a Close shift button only after the cutoff. The internal format uses a 24-hour clock with leading zeros, so the strings compare correctly regardless of the user's display format.

    var currentTime = mgs.nowGlideDateTime().getLocalTime().getDisplayValueInternal();
            var pastCutoff = currentTime > '17:00:00';
            mgs.info('Past cutoff: ' + pastCutoff);

Output:

    Past cutoff: false

## MobileGlideTime - getHourLocalTime() / getHourUTC() {#ariaid-title5}

Gets the hour of the time of day on a 12-hour clock, in the user's time zone or in UTC.
`getHourLocalTime()` returns the hour in the user's local time zone; `getHourUTC()` returns the equivalent hour in UTC.
{#MGT-getHourLocalTime_getHourUTC__table_MGT-getHourLocalTime_getHourUTC_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 7. Parameters]

{#MGT-getHourLocalTime_getHourUTC__table_MGT-getHourLocalTime_getHourUTC_p} {#MGT-getHourLocalTime_getHourUTC__table_MGT-getHourLocalTime_getHourUTC_r__entry__2}

| Type | Description |
|-|-|
| Number | Hour on a 12-hour clock. Range: 0 to 11. A value of 0 represents both 12:00 AM and 12:00 PM. |
[Table 8. Returns]

{#MGT-getHourLocalTime_getHourUTC__table_MGT-getHourLocalTime_getHourUTC_r}  
This example gets the hour of the current local time on a 12-hour clock and logs it.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getHourLocalTime());

Output:

    4

This example builds a readable hour label with AM or PM. The 12-hour value is 0 for both noon and midnight, so the script shows 12 in that case and uses the 24-hour value to tell AM from PM.

    var time = mgs.nowGlideDateTime().getLocalTime();
            var hour12 = time.getHourLocalTime();
            var displayHour = hour12 === 0 ? 12 : hour12;
            var period = time.getHourOfDayLocalTime() < 12 ? 'AM' : 'PM';
            mgs.info('Local hour: ' + displayHour + ' ' + period);

Output:

    Local hour: 4 PM

This example builds a readable hour label in UTC with AM or PM, such as to show users the UTC time of a scheduled job. The 12-hour value is 0 for both noon and midnight, so the script shows 12 in that case and uses the 24-hour value to tell AM from PM.

    var time = mgs.nowGlideDateTime().getTime();
            var hour12 = time.getHourUTC();
            var displayHour = hour12 === 0 ? 12 : hour12;
            var period = time.getHourOfDayUTC() < 12 ? 'AM' : 'PM';
            mgs.info('UTC hour: ' + displayHour + ' ' + period);

Output:

    UTC hour: 8 PM

## MobileGlideTime - getHourOfDayLocalTime() / getHourOfDayUTC() {#ariaid-title6}

Gets the hour of the time of day on a 24-hour clock, in the user's time zone or in UTC.
`getHourOfDayLocalTime()` returns the hour in the user's local time zone; `getHourOfDayUTC()` returns the equivalent hour in UTC.
{#MGT-getHourOfDayLocalTime_getHourOfDayUTC__table_MGT-getHourOfDayLocalTime_getHourOfDayUTC_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 9. Parameters]

{#MGT-getHourOfDayLocalTime_getHourOfDayUTC__table_MGT-getHourOfDayLocalTime_getHourOfDayUTC_p} {#MGT-getHourOfDayLocalTime_getHourOfDayUTC__table_MGT-getHourOfDayLocalTime_getHourOfDayUTC_r__entry__2}

| Type | Description |
|-|-|
| Number | Hour on a 24-hour clock. Range: 0 to 23. |
[Table 10. Returns]

{#MGT-getHourOfDayLocalTime_getHourOfDayUTC__table_MGT-getHourOfDayLocalTime_getHourOfDayUTC_r}  
This example gets the hour of the current local time on a 24-hour clock and logs it.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getHourOfDayLocalTime());

Output:

    16

This example works out which shift the current local time falls in, such as to label a work log. The day shift runs from 6:00 AM to 2:00 PM, the evening shift from 2:00 PM to 10:00 PM, and the night shift covers the rest.

    var hour = mgs.nowGlideDateTime().getLocalTime().getHourOfDayLocalTime();
            var shift = 'Night';
            if (hour >= 6 && hour < 14) {
            shift = 'Day';
            } else if (hour >= 14 && hour < 22) {
            shift = 'Evening';
            }
            mgs.info('Current shift: ' + shift);

Output:

    Current shift: Evening

This example checks whether the current time falls within a nightly sync window that's defined in UTC, from 02:00 to 04:00. A button condition can use this check to hide a Sync now button while the nightly sync runs.

    var hour = mgs.nowGlideDateTime().getTime().getHourOfDayUTC();
            var inSyncWindow = hour >= 2 && hour < 4;
            mgs.info('UTC hour: ' + hour + ', in sync window: ' + inSyncWindow);

Output:

    UTC hour: 20, in sync window: false

## MobileGlideTime - getMinutesLocalTime() / getMinutesUTC() {#ariaid-title7}

Gets the minutes of the time of day, in the user's time zone or in UTC.
`getMinutesLocalTime()` returns the minutes in the user's local time zone; `getMinutesUTC()` returns the equivalent minutes in UTC.
{#MGT-getMinutesLocalTime_getMinutesUTC__table_MGT-getMinutesLocalTime_getMinutesUTC_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 11. Parameters]

{#MGT-getMinutesLocalTime_getMinutesUTC__table_MGT-getMinutesLocalTime_getMinutesUTC_p} {#MGT-getMinutesLocalTime_getMinutesUTC__table_MGT-getMinutesLocalTime_getMinutesUTC_r__entry__2}

| Type | Description |
|-|-|
| Number | Minutes after the hour. Range: 0 to 59 |
[Table 12. Returns]

{#MGT-getMinutesLocalTime_getMinutesUTC__table_MGT-getMinutesLocalTime_getMinutesUTC_r}  
This example gets the minutes of the current local time and logs them.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getMinutesLocalTime());

Output:

    44

This example finds the start of the 15-minute appointment slot that the current time falls in, such as for a scheduling form.

    var minutes = mgs.nowGlideDateTime().getLocalTime().getMinutesLocalTime();
            var slotStart = Math.floor(minutes / 15) * 15;
            mgs.info('Appointment slot starts at minute ' + slotStart);

Output:

    Appointment slot starts at minute 30

This example calculates how many minutes remain until the next scheduled sync. Syncs run every 30 minutes, on the hour and half hour in UTC.

    var minutes = mgs.nowGlideDateTime().getTime().getMinutesUTC();
            var minutesUntilSync = 30 - (minutes % 30);
            mgs.info('Next sync in ' + minutesUntilSync + ' minutes');

Output:

    Next sync in 16 minutes

## MobileGlideTime - getSeconds() {#ariaid-title8}

Gets the seconds of the time of day.
{#MGT-getSeconds__table_MGT-getSeconds_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 13. Parameters]

{#MGT-getSeconds__table_MGT-getSeconds_p} {#MGT-getSeconds__table_MGT-getSeconds_r__entry__2}

| Type | Description |
|-|-|
| Number | Seconds after the minute. Range: 0 to 59. |
[Table 14. Returns]

{#MGT-getSeconds__table_MGT-getSeconds_r}  
This example gets the seconds of the current local time and logs them.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getSeconds());

Output:

    17

This example converts the current local time to the number of seconds since midnight, such as to compare two times of day to the second.

    var time = mgs.nowGlideDateTime().getLocalTime();
            var secondsSinceMidnight = time.getHourOfDayLocalTime() * 3600 + time.getMinutesLocalTime() * 60 + time.getSeconds();
            mgs.info('Seconds since midnight: ' + secondsSinceMidnight);

Output:

    Seconds since midnight: 60257

## MobileGlideTime - getValue() {#ariaid-title9}

Gets the time of day in the internal format.
{#MGT-getValue__table_MGT-getValue_p__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 15. Parameters]

{#MGT-getValue__table_MGT-getValue_p} {#MGT-getValue__table_MGT-getValue_r__entry__2}

| Type | Description |
|-|-|
| String | Time of day in the internal format, `HH:mm:ss`. |
[Table 16. Returns]

{#MGT-getValue__table_MGT-getValue_r}  
This example gets the current local time of day in the internal format and logs it.

    mgs.info(mgs.nowGlideDateTime().getLocalTime().getValue());

Output:

    16:44:17

This example joins the local date and the local time of day, both in the internal format, to build a date and time string for a visit record.

    var gdt = mgs.nowGlideDateTime();
            var visitTime = gdt.getLocalDate().getValue() + ' ' + gdt.getLocalTime().getValue();
            mgs.info(visitTime);

Output:

    2026-08-26 16:44:17


