User Manual
Print

Using the Current Time to Display DateTimeOffset

Create datetimeoffset using current time

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>dateTimeOffset</variable></variables><block type=\"DateTime_now\" disabled=\"true\" x=\"-22\" y=\"337\"/></xml>"}
				
			

This block is used to generate a new DateTimeOffset using current time.

Parameters: N/A

Output: DateTimeOffset

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_consoleLogText\"><value name=\"text\"><block type=\"DateTime_DateTimeOffset_toString\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value></block></value></block></next></block></statement></block></xml>"}
				
			

The output:

Create datetimeoffset using current time - Output