UPDATE_MILLISECOND

The function UPDATE_MILLISECOND changes the value of the millisecond in a Time or DateTime into another specified number.

This function takes two pieces of input: a Time or a DateTime, and a Number. It outputs the given Time or Datetime with the value of the millisecond replaced by the given number.

 

Declaration

UPDATE_MILLISECOND(datetime, new_millisecond) -> new_datetime
UPDATE_MILLISECOND(time, new_millisecond) -> new_time

Parameters

datetime (type: DateTime)
Any DateTime.

time (type: Time)
Any Time.

new_second (required, type: Number)
The new millisecond; this is the number that will replace whatever value is currently associated with the millisecond in the given Time or DateTime.

Return Values

new_datetime (type: DateTime)
The DateTime that results from taking a given DateTime and replacing the millisecond value with the given number.

new_time (type: Time)
The Time that results from taking a given Time and replacing the millisecond value with the given number.

Examples

Assume the first example has access to the following DateTime value:

example_date_and_time = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}

The following example takes the time described in example_date_and_time and replaces the given millisecond value (0) with 30. Note that the only difference between the output of this example and example_date_and_time is the the value of the millisecond. When given a DateTime as input, UPDATE_MILLISECOND returns a DateTime:

UPDATE_MILLISECOND(example_date_and_time, 30) = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 30  
 },  
 "timeZone": "UTC"  
}

The above example demonstrates how the UPDATE_MILLISECOND function behaves when given a DateTime as input. In order to further establish how the UPDATE_MILLISECOND function behaves when given a Time as input, assume the last example has access to the following Time value:

example_time = {  
 "hour": 16,  
 "minute": 14,  
 "second": 38,  
 "millisecond": 0  
}

The following example takes the time described in example_time and replaces the given millisecond value (0) with 30. Note that the only difference between the output of this example and example_time is the the value of the millisecond. When given a Time as input, UPDATE_MILLISECOND outputs a Time:

UPDATE_MILLISECOND(example_time, 2) = {  
 "hour": 16,  
 "minute": 14,  
 "second": 38,  
 "millisecond": 30  
}