[Tutor] datetime year problem, default year available?

Sander Sweers sander.sweers at gmail.com
Sat Jan 31 14:28:03 CET 2009

On Tue, Jan 27, 2009 at 01:01, Sander Sweers <sander.sweers at gmail.com> wrote:
> month ('11/27' for example). Now when I use datetime.strptime('11/27',
> ''%m/%d) I get a datetime object but the year is 1900. This makes
> sense as I did not provide one.
> Then I saw that a datetime object has a replace function so now I
> could replace a 1900 by 2008 (we can assume the year is 2008). Then we
> can do datetime.strptime('11/27', '%m/%d').replace(year=2008).

I could also do do datetime.strptime('11/27' + '/09', '%m/%d/%y').

Which solution would be recommended to use?


More information about the Tutor mailing list