Hello,
How to get formatted date time in Python the same way as in PHP
date('M d Y', $timestamp);
?
Hello,
How to get formatted date time in Python the same way as in PHP
date('M d Y', $timestamp);
?
You can use a suitable strftime
function. Here is an example using datetime
objects.
>>> from datetime import datetime
>>> today = datetime.today()
>>> today.strftime("%m %d %Y")
'09 13 2010'
>>> import time
>>> timestamp = 1284375159
>>> time.strftime("%m %d %Y",time.localtime(timestamp))
'09 13 2010'