-
-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output a timestamp with UTC designator 'Z' #256
Comments
I also miss an option to output the timezone name (such as CEST, BRT, PT, etc) when using |
+1 |
I just got bitten by the same issue. For the purposes of moving forward I just conditionally replace the verbose timezone info with Z. I also needed to be explicit with the format so manually defined it rather than using the built in .isoformat() function (although it appeared to give the same results in this case)
I also need to go the other way and parse the timestamp_str only if it matches this iso format string. I had to pre-process my string simialrly: |
Is the code below helpful?
Following this answer: https://stackoverflow.com/a/42777551/5772365. |
Once we implement #35 then something like this would work. >>> dt=arrow.utcnow()
>>> dt
<Arrow [2019-07-28T16:23:29.819198+00:00]>
>>> dt.format("YYYY-MM-DDTHH:mm:ssZ")
'2019-07-28T16:23:29+0000'
>>> dt.format("YYYY-MM-DDTHH:mm:ss[Z]")
'2019-07-28T16:23:29Z' |
Now that #688 has been merged the example I posted above will work! |
I know this thread is closed, but for those who stumble across it and are copy/pasting the solution above, please note that if you are trying to render time into ISO 8601 then you'll want the 24 hour formatting option ("HH") rather than the 12-hour option ("hh"). (And if you are not trying to be ISO 8601 compliant then you'll probably want am/pm ("A", or "a") in there somewhere). Incorrect (hh):
Correct (HH):
Thanks for the snippet @systemcatch ; it got me (eventually) where I needed to be. Cheers! |
@epmoyer glad it helped you, I've corrected my snippet. |
Is it possible to output a timestamp formatted with a UTC designator 'Z' instead of '+00:00'?
E.g. eventbrite api requires the form:
YYYY-MM-DDThh:mm:ssZ
, but it only accepts UTC timezone formatted specifically as2015-02-15T11:35:00Z
.I can't seem to find a way to force arraow (or dateutil) to output 'Z'.
P.S.: I know I can append 'Z' myself, but that's not what I am looking for.
The text was updated successfully, but these errors were encountered: