الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

time and datetime

بدأه the.scorpion في 29 مارس 2014 · 0 رد · 410 مشاهدة · في لغة Python
مشاركة: واتساب X فيسبوك تيليجرام
#1

import time

import datetime

print "Time in seconds since the epoch: %s" %time.time()

print "Current date and time: " , datetime.datetime.now()

print "Or like this: " ,datetime.datetime.now().strftime("%y-%m-%d-%H-%M")

print "Current year: ", datetime.date.today().strftime("%Y")

print "Month of year: ", datetime.date.today().strftime("%B")

print "Week number of the year: ", datetime.date.today().strftime("%W")

print "Weekday of the week: ", datetime.date.today().strftime("%w")

print "Day of year: ", datetime.date.today().strftime("%j")

print "Day of the month : ", datetime.date.today().strftime("%d")

print "Day of week: ", datetime.date.today().strftime("%A")

mydate = datetime.date(1943,3, 13) #year, month, day

print(mydate.strftime("%A"))

now = datetime.datetime.now()

print "-" * 25

print now

print now.year

print now.month

print now.day

print now.hour

print now.minute

print now.second

print "-" * 25

print "1 week ago was it: ", now - datetime.timedelta(weeks=1)

print "100 days ago was: ", now - datetime.timedelta(days=100)

print "1 week from now is it: ", now + datetime.timedelta(weeks=1)

print "In 1000 days from now is it: ", now + datetime.timedelta(days=1000)

print "-" * 25

birthday = datetime.datetime(2012,11,04)

print "Birthday in ... ", birthday - now

print "-" * 25

1

مواضيع مشابهة