# CHANGETIMESTAMP

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

# Description

The CHANGETIMESTAMP function can be used to adjust existing timestamp to return a new timestamp value. It may take the form:

CHANGETIMESTAMP(Timestamp, Array)
1

Where the format of the adjustment array can be : Years^Months^Weeks^Days^Hours^Minutes^Seconds^Milliseconds

The function generates a new timestamp by adjusting an existing timestamp value using the elements specified in the dynamic array.

An example of usage is as follows:

    current_time = MAKETIMESTAMP(DATE(), TIME(), '')
    CRT "Current time in UTC is  " : current_time
    CRT "Current local time is   " : OCONV(OCONV(current_time, "U0FF0"),"MTS")
    CRT "Current local date is   " : OCONV(OCONV(current_time, "U0FF1"),"D4")
* Add 100 milliseconds
    adjusted_array = ''
    adjusted_array<8> = 100
    new_time = CHANGETIMESTAMP(current_time, adjusted_array)
    CRT "Adjusted time in UTC is " : new_time
    CRT "Adjusted local time is  " : OCONV(OCONV(new_time, "U0FF0"),"MTS")
    CRT "Adjusted local date is  " : OCONV(OCONV(new_time, "U0FF1"),"D4")
* Add 10 years
    adjusted_array<8> = ''
    adjusted_array<1> = 10
    new_time = CHANGETIMESTAMP(current_time, adjusted_array)
    CRT "Adjusted time in UTC is " : new_time
    CRT "Adjusted local time is  " : OCONV(OCONV(new_time, "U0FF0"),"MTS")
    CRT "Adjusted local date is  " : OCONV(OCONV(new_time, "U0FF1"),"D4")

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

which results in the following output:

Current time in UTC is  1585835025.1
Current local time is   14:43:45
Current local date is   02 APR 2020
Adjusted time in UTC is 1585835025.2
Adjusted local time is  14:43:45
Adjusted local date is  02 APR 2020
Adjusted time in UTC is 1901367825.1
Adjusted local time is  14:43:45
Adjusted local date is  02 APR 2030
1
2
3
4
5
6
7
8
9

Go back to jBASE BASIC

Go back to Programmers' Reference Guide