Difference between revisions of "Programming language cook book"

From Review or Discard at Will
Jump to: navigation, search
(Python)
(Python)
Line 8: Line 8:
 
print (arrow.get(arrow.utcnow()).for_json()
 
print (arrow.get(arrow.utcnow()).for_json()
  
results in: "2015-08-27T15:03:07.427351+00:00" I'd like to trim it further and replace the +00:00 with Z. ???
+
results in: "2015-08-27T15:03:07.427351+00:00" I'd like to trim it further and replace the +00:00 with Z. ??? and less precision on the seconds.
 
</source>
 
</source>
 +
 +
Documentation for [https://en.wikipedia.org/wiki/ISO_8601 ISO 8601]
  
 
==Mediawiki==
 
==Mediawiki==

Revision as of 08:30, 27 August 2015

Mostly just for me to remember stuff

Python

I wanted a json utc datetime for a MQTT payload. Found the arrow module that is much like moment.js for javascript.

import arrow
print (arrow.get(arrow.utcnow()).for_json()

results in: "2015-08-27T15:03:07.427351+00:00" I'd like to trim it further and replace the +00:00 with Z. ??? and less precision on the seconds.

Documentation for ISO 8601

Mediawiki

display unformated like code snippets

<source lang="text"> code snippet </source>