I have a datetime object got from a mysql database I found that its format is following the system datetime format. Therefore, the format constantly changes and it might contain other types of characters (depending on the system), which is very annoying.
Also, I can't use function like strftime to manipulate it.
I did a query from database:
results = myfunction.query("SELECT date FROM users WHERE id = 1")
and I got this [<System.DateTime object at 0x0000000000000080 [10/01/2020 13:14:56]>]
the column date is only a normal datetime column in a mysql database.
Then, I choose the 0th element of results:
result = results[0]
When I print the type of 'result', I got this <type 'DateTime'>
print type(result)
Then I use str() to convert result into a string.
print str(result)
I got this string '10/01/2020 13:14:56'
However, when I use another computer
I got this: 2020/10/01 下午 01:14:56 (probably following the windows default datetime format)
I am not able to manipulate the 'result' using strftime like:
result.strftime('Y-m-d')
My question is: How to get a unified format of the datetime in my case?