ILM-FAN VA INNOVATSIYA
ILMIY-AMALIY KONFERENSIYASI
in-academy.uz/index.php/si
137
WORKING WITH DATE AND TIME IN PYTHON
Onarkulov Maqsadjon Karimberdiyevich
Fergana state university practical mathematics and
Department of Informatics associate professor
Yusupov Mirsaid Abdulaziz son
Fergana state university practical mathematics and
computer science department teacher
Numonova Malohat Akmaljon daughter
Fergana State 3rd year university student
https://doi.org/10.5281/zenodo.15593106
Annotation.
Python is dedicated to learning ways to work with date and time in the
programming language. Python's datetime module allows you to perform basic operations such
as getting the current date and time, creating exact date and time objects, formatting time, and
converting an object to string. It also covers the calculation of the difference between two dates,
the addition or subtraction of time, and the work with time zones. Working with dates and times
is widely used in programming, allowing for efficient tasks such as time-dependent calculations
and formatting. This topic provides programmers with important knowledge and practical
skills in solving real-world time-related problems.
Keywords:
measure time, calculate for a specific date, change time format.
Datetime
.
The Python programming language is a ready-made module for defining the current date
and performing operations on dates, called datetime
.
1. Overview of Datetime Module
The datetime module is a standard library in Python that lets you work with dates, times,
and a combination of dates.
Basic classes in the module:
Date — only date (year, month, day)
Time—only time (hours, minutes, seconds, microseconds)
Datetime — Date and Time Together
timedelta — vaqt farqi yoki interval
A date includes years, months, days, hours, minutes, seconds, and microseconds. The
module contains many ways to return data about datetime date object. We'll release the year
and week day with you at the current time.
Create date objects
We can use the module datetime ()
class (constructor) to create dates
. To create a date
datetime (),
the class requires three parameters: year, month, day.
ILM-FAN VA INNOVATSIYA
ILMIY-AMALIY KONFERENSIYASI
in-academy.uz/index.php/si
138
strftime() function
The object
has a method of formatting datetimeana objects into readable strings.
To
define the line format,
strftime()
takes one parameter.
Create date and time object from string
strptime()
method converts the date in the text to
a datetime
object.
Calculate the time difference
The difference between two dates can be calculated using
timedelta.
Reference:
%a
- Weekly Short Name (Wed)
%A
- Hafta kunining to'liq nomi (Wednesday)
%w
- What day of the weekday, i.e. on what day of the week, until 0 - 6 (3)
%d
- Lunar Day (31)
%b
- Short Name of the month (Dec)
%B
- Full Name of the month (December)
ILM-FAN VA INNOVATSIYA
ILMIY-AMALIY KONFERENSIYASI
in-academy.uz/index.php/si
139
%m
- Months in numbers 01 - 12 (12)
%y
is the short number of the year, the last two digits (22)
%Y
– Full Name of the Year (2022)
%H
- Soat tariflash 00 - 23 (18)
%I
- Soat ta'riflash 00 - 12 (09)
%p
- Soat ta'riflash AM/PM (PM)
%M
- Minute ta'riflash 00 - 59 (35)
%s
- Seconds 00 - 59 (09)
%f
- millisecond 000000-999999 (465845)\
%Z
- TimeZone (CST)
%j
- Year's Day 001 - 366 (263)
%C
- Release Century (21)
So
:
Python's datetime module allows you to perform basic operations such as getting the
current date and time, creating exact date and time objects, formatting time, and converting an
object to string. It also covers the calculation of the difference between two dates, the addition
or subtraction of time, and the work with time zones. Working with dates and times is widely
used in programming, allowing for efficient tasks such as time-dependent calculations and
formatting. This topic provides programmers with important knowledge and practical skills in
solving real-world time-related problems.
References:
Используемая литература:
Foydalanilgan adabiyotlar:
1.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). ADVANTAGES AND
DISADVANTAGES OF ARTIFICIAL INTELLIGENCE.
RESEARCHER
,
1
(1), 75-85.
2.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). NEUROCOMPUTERS.
NEW
UZBEKISTAN, JOURNAL OF NEW STUDIES
,
1
(5), 19-27.
3.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). K-CLOSE NEIGHBOR ALGORITHM.
THE RESEARCHER
,
1
(1), 122-124.
4.
Abdulaziz o'g'li, Y. M. (2025). WPFDA ANIMATSIYA YARATISHNI QO’LLANISHI.
MODERN
PROBLEMS IN EDUCATION AND THEIR SCIENTIFIC SOLUTIONS
,
1
(4), 172-175.
5.
Abdulaziz son, Y. M. (2025). WORK WITH WPF IN FINANCE AND ACCOUNTING
APPLICATIONS.
MODERN PROBLEMS IN EDUCATION AND THEIR SCIENTIFIC SOLUTIONS
,
1
(4),
189-193.
6.
Karimberdiyevich, O. M. (2024). NEUROEMULATORS AND THEIR APPLICATIONS.
JOURNAL OF NEW STUDIES
,
1
(5), 82-89.
7.
Abdulaziz Ogli, Y. M. (2025). PRACTICAL APPLICATIONS OF WORKING WITH TWO-
DIMENSIONAL AND THREE-DIMENSIONAL GRAPHICS IN WPF.
MODERN PROBLEMS IN
EDUCATION AND THEIR SCIENTIFIC SOLUTIONS
,
1
(4), 176-179.
8.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). CLASSIFICATION AND
REGRESSION IN MACHINE LEARNING. RESEARCHER, 1(1), 114-121.
9.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). CREATE AND EDIT A PIVOT
CHART. JOURNAL OF NEW STUDIES, 1(5), 28-30.
ILM-FAN VA INNOVATSIYA
ILMIY-AMALIY KONFERENSIYASI
in-academy.uz/index.php/si
140
10.
Karimberdiyevich, O. M., & Abdulaziz son, Y. M. (2024). CLASSIFICATION AND
REGRESSION IN MACHINE LEARNING.
THE RESEARCHER
,
1
(1), 114-121.