Date et heure

sylpard - 5 juil. 2017 à 16:09
didoux95 Messages postés 845 Date d'inscription mardi 25 avril 2006 Statut Membre Dernière intervention 1 août 2017 - 1 août 2017 à 10:58
Bonjour, j'ai le script suivant et j' aimerais ajouter la date du jour .

il faut ajouter la ligne :time.strftime('%d/%m/%y', time.localtime())

mais je ne sais pas ou l' indiquer

pouvez vous m' aider ?


time1 = ''
clock = Label(root, font=('times', 20, 'bold'), bg='black', fg='white')
clock.pack(fill=BOTH, expand=1)
def tick():
global time1
# get the current local time from the PC
time2 = time.strftime('%H:%M:%S')
#time3 = time.strftime('%d/%m/%y', time.localtime())
# if time string has changed, update it
if time2 != time1:
time1 = time2
clock.config(text=time2)
# calls itself every 200 milliseconds
# to update the time display as needed
# could use >200 ms, but display gets jerky
clock.after(200, tick)
tick()



Merci !

1 réponse

didoux95 Messages postés 845 Date d'inscription mardi 25 avril 2006 Statut Membre Dernière intervention 1 août 2017 2
1 août 2017 à 10:58
Salut,

Un petit tour sur https://docs.python.org te permettra d'avoir toutes ces infos: https://docs.python.org/2/library/time.html#time.strftime

import time
time.strftime("%d/%m/%Y %H:%M:%S", time.localtime())


@+
0
Rejoignez-nous