User Manual
Print

Changing the Format of DateTimeOffset to Text Format

dateTimeOffset to string with format

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>dateTimeOffset</variable></variables><block type=\"DateTime_DateTimeOffset_toFormat\" disabled=\"true\" x=\"-22\" y=\"427\"><value name=\"dateTimeOffset\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"format\"><shadow type=\"text\" disabled=\"true\"><field name=\"TEXT\">yyyy-MM-dd HH:mm:ss ZZ</field></shadow></value></block></xml>"}
				
			

This block is used to change the DateTimeOffset to a specific string format. 

Parameters: 

      • DateTimeOffset
      • String

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_toFormat\"><value name=\"dateTimeOffset\"><block type=\"variables_get\"><field name=\"VAR\">dateTimeOffset</field></block></value><value name=\"format\"><shadow type=\"text\"><field name=\"TEXT\">yyyy-MM-dd HH:mm:ss ZZ</field></shadow></value></block></value></block></next></block></statement></block></xml>"}
				
			

The output:

dateTimeOffset to string with format - Output