How to pick time only in Datetime field in odoo 10
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客戶關係
- e-Commerce
- 會計
- 庫存
- PoS
- Project
- MRP
此問題已被標幟
5
回覆
12591
瀏覽次數
How to pick time only in Datetime field in odoo 10
import datetime
string = '2018-05-17 10:44:50'
dt = datetime.datetime.strptime(string,'%Y-%m-%d %H:%M:%S')
print dt.time()
print dt.time().hour
print dt.time().minute
# output
10:44:50
10
44
dt = datetime.datetime.strptime(string,'%Y-%m-%d %H:%M:%S')
time = dt.time()
date = dt.date()
check_in_date = datetime.strptime(check_in, "%Y-%m-%d %H:%M:%S").date()
Hello
from datetime import datetime
date = field.Datetime(string='Date')
On_your_method
get_time = datetime.datetime.strptime(date,'%Y-%m-%d %H:%M:%S')
final_time = get_time.time()
print "final time", final_time
相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
---|---|---|---|---|
|
1
9月 19
|
13174 | ||
|
2
7月 25
|
4483 | ||
|
2
12月 24
|
7666 | ||
|
2
11月 24
|
28428 | ||
|
2
5月 24
|
7399 |
Date manipulation in python:
1- http://learnopenerp.blogspot.com/2018/01/python-date-manipulation.html
2- http://learnopenerp.blogspot.com/2018/02/python-strftime-datetime-formatting.html
3- http://learnopenerp.blogspot.com/2018/02/python-timedelta.html
Hope it will works for you.