Showing posts with the label Operations with dates

Python - Operations with dates

Formatting dates and times The strftime(format) method is used to format date objects and time objects in both classes. The strftime(format) method takes only one argument and returns the format that the date or time object should be formatted in. The following formatting codes can be used to specify the format: %a : Abbreviation for the day of the week. For example, Sun- from the word Sunday %A : day of the week in full, e.g. Sunday %b : Abbreviation for the month name. For example, Oct (short for October) %B : month name in full, e.g. May %d : day of the month, padded with a zero, e.g. 01 %m : month number, padded with zero, e.g. 05 %y : year as 2 numbers %Y : year as 4 numbers %H : hour in 24 hour format, e.g. 13 %I : hour in 12 hour format, e.g. 01 %M : minutes %S : second %f : microsecond %p : AM/PM pointer %c : date and time formatted for the current locale %x : date formatted for the current locale %X : time formatted for the current locale We use various formats : from datetim