<br><br><div><span class="gmail_quote">On 8/16/07, <b class="gmail_sendername">special_dragonfly</b> <<a href="mailto:Dominic@pleaseask.co.uk">Dominic@pleaseask.co.uk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br><br>I need to return the date yesterday in the form DDMMYYYY. I looked through<br>the modules: time, datetime and calendar but can't find anything that leaps<br>out at me.<br><br>The problem I'm having is that although I can use
time.localtime and get a<br>tuple of the year, month, day and so forth, I don't believe I can just minus<br>1 from the day, because I don't think it's cyclic, also, I can't see the<br>date being linked in with the month.
<br><br>So is there any way of getting yesterdays date?<br><br>Thank You<br><br>Dominic<br><br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a>
</blockquote><div><br></div>The easiest way I have found, is to use epoch, subtract the length of time, then convert back to whatever format.
24 hours is 86400 seconds.</div>
<br>>>> import time<br>
>>> time.localtime()<br>
(2007, 8, 16, 9, 41, 28, 3, 228, 1)<br>
>>> time.localtime(time.time() - 86400)<br>
(2007, 8, 15, 9, 41, 21, 2, 227, 1)<br>