User Manual
Print

Showing DateTimeOffset in Different Time Format

dateTimeOffset get year

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>dateTimeOffset</variable><variable>unixTime</variable></variables><block type=\"DateTime_DateTimeOffset_get\" disabled=\"true\" x=\"-23\" y=\"158\"><field name=\"unit\">DateTimeUnit.Year</field><value name=\"dateTimeOffset\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></xml>"}
				
			

This block is used to show the time in different format.

Parameters:

        • DateTimeOffset
        • Condition: Year (Default)/Month/Day/Hour/Minute/Second/Millisecond/Offset/WeekYear/WeekNumber/WeekDay

Output: Number

Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>dateTimeOffset</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">dateTimeOffset</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"DateTime_now\"/></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"DateTime_DateTimeOffset_get\"><field name=\"unit\">DateTimeUnit.Year</field><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></next></block></statement></block></xml>"}
				
			

The output:

dateTimeOffset get year - Output