In this article we will learn about some of the frequently asked HTML programming questions in technical like “time.mktime” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on html was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in HTML. Below are some solution about “time.mktime” Code Answer’s.
time.strftime
xxxxxxxxxx
1
from datetime import datetime
2
3
timestamp = 1528797322
4
date_time = datetime.fromtimestamp(timestamp)
5
6
print("Date time object:", date_time)
7
8
d = date_time.strftime("%m/%d/%Y, %H:%M:%S")
9
print("Output 2:", d)
10
11
d = date_time.strftime("%d %b, %Y")
12
print("Output 3:", d)
13
14
d = date_time.strftime("%d %B, %Y")
15
print("Output 4:", d)
16
17
d = date_time.strftime("%I%p")
18
print("Output 5:", d)
19
time.mktime
xxxxxxxxxx
1
#!/usr/bin/python3
2
import time
3
import datetime
4
5
start = "10/03/2021 08:00:00"
6
timestmp_start=int(time.mktime(datetime.datetime.strptime(start, "%d/%m/%Y %H:%M:%S").timetuple()))*1000
7
date_start=datetime.datetime.fromtimestamp(timestmp_start/1000).strftime("%d/%m/%Y %H:%M:%S")
8
9
10
#output:
11
#timestmp_start: 1615343400000
12
#date_start: "10/03/2021 08:00:00"