Pytz, Create Local Unix Time

Subscribe dengan Account Google untuk mendapatkan News Letter terbaru dari Halovina !
Pytz, Create Local Unix Time
Apa 10 Ltr Air Cooler 1200cmh - Putih

Apa 10 Ltr Air Cooler 1200cmh - Putih

Hadirkan kesejukan di ruangan Anda dengan air cooler dari APA. Penyejuk udara ini dilengkapi dengan kapasitas kontainer air sebesar 10 liter yang ideal untuk kebutuhan harian keluarga Anda. 3 pilihan kecepatan kipas dapat Anda pilih dengan mudah, lengkap dengan 4 pilihan mode yaitu ionizer, humidifier, swing, atau cool sesuai dengan kebutuhan Anda. Pilihan timer dapat mempermudah Anda mengatur jadwal operasi dari alat ini.

Free Klik Disini !

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher. It also solves the issue of ambiguous times at the end of daylight saving time, which you can read more about in the Python Library Reference.

How to change human time to unix time ?

- create a function, this function will be used to change local unix time

import pytz
import time
from datetime import datetime

def convert_to_unix(date_time):
localtz = pytz.timezone('Asia/Jakarta')
date_aware_la = localtz.localize(date_time).strftime("%Y-%m-%d %H:%M:%S")
source_time = time.strptime(date_aware_la, "%Y-%m-%d %H:%M:%S")
created_date_unix = time.mktime(source_time)
return created_date_unix

date_now = convert_to_unix(datetime.now())
print(date_now)

how to install pytz ?

- pip install pytz or easy_install pytz

doc : https://pypi.python.org/pypi/pytz

read others article :