forked from dl111122/playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time Conversion P.py
35 lines (34 loc) · 1.09 KB
/
Time Conversion P.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import datetime
>>> datetime.datetime.fromtimestamp(1437514227)
datetime.datetime(2015, 7, 21, 14, 30, 27)
>>>
>>> from datetime import datetime
>>>
>>> from time import gmtime, strftime
>>> strftime ("%a, %d %b %Y %H:%M:%S", gmtime (1437514227))
'Tue, 21 Jul 2015 21:30:27'
>>>
>>> import time
>>>
>>> from time import gmtime, strftime
>>> strftime ("%b %d, %Y %H:%M:%S %P", gmtime (1437514227))
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
strftime ("%b %d, %Y %H:%M:%S %P", gmtime (1437514227))
ValueError: Invalid format string
>>>
>>> from time import gmtime, strftime
>>> strftime ("%b %d, %Y %H:%M:%S", gmtime (1437514227))
'Jul 21, 2015 21:30:27'
>>>
>>> from time import gmtime, strftime
>>> strftime ("b %d, %Y %H:%M:%S %p", gmtime (1437514227))
'b 21, 2015 21:30:27 PM'
>>>
>>>
>>> from time import gmtime, strftime
>>> strftime ("%b %d, %Y %H:%M:%S %p", gmtime (1437514227))
'Jul 21, 2015 21:30:27 PM'
>>>