Main Content

To DateTime

R2026b

Output DateTime signal

Since R2026b

  • To DateTime block icon

Libraries:
Simulink / DateTime

Description

The To DateTime block outputs a DateTime signal from a time point.

Examples

expand all

This example shows how the To DateTime block converts a numerical signal to a DateTime signal. The block's input is a constant signal with value 1788253200. The block's output is a signal containing the DateTime value 01-Sep-2026 09:00:00, which is 1788253200 seconds after the Unix epoch (01-Jan-1970 00:00:00).

model='ex_to_datetime_block';
load_system(model)
sim(model);
open_system(model)

Ports

Input

expand all

Input time, specified as a scalar numeric.

Dependencies

The data type for this input port must be the same as the data type specified in the Storage data type parameter.

Data Types: double | int32 | uint32 | fixed point

Output

expand all

Value of DateTime signal, returned as a scalar.

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Choose the data type for the output. The type can be specified directly as Simulink.DateTimeType() or expressed as a Simulink.DateTimeType data type object.

  • Simulink.DateTimeType(Name,value)

  • Simulink.DateTimeType(datetime type name)

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

To get the block parameter value programmatically, use the get_param function.

Parameter: OutDataTypeStr
Values: Simulink.DateTimeType() (default) | <data type expression>

Select the category of data to specify.

  • DateTimeSimulink.DateTimeType() data types.

  • Expression — Expressions that evaluate to data types. Selecting Expression enables a second text box to the right, where you can enter the expression.

For more information, see Specify Data Types Using Data Type Assistant.

Select the time point:

  • Seconds since Unix epoch

  • Seconds since NTP epoch

  • Seconds since TAI epoch

  • Julian date

  • Modified Julian date

  • J2000.0 date

For more information on storage type constraints, see Simulink.DateTimeType.

For more information, see Specify Data Types Using Data Type Assistant.

Select the DateTime storage data type:

  • double

  • int32

  • uint32

  • fixdt(0,64,32)

  • fixdt(1,64,32)

  • fixdt(0,128,64)

  • fixdt(1,128,64)

For more information on storage type constraints, see Simulink.DateTimeType.

Dependencies

The data type for the Port_1 input port must be the same as the data type specified in the Storage data type parameter.

Select the DateTime time standard:

  • TAI

  • UTC

  • TT

For more information on storage type constraints, see Simulink.DateTimeType.

Block Characteristics

Data Types

Boolean | bus | datetime | double | fixed point | integer

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2026b