# Python zipfile: writestr(name, data) stamps current time, but a bare ZipInfo(name) has date_time (1980, 1, 1, 0, 0, 0)

- Source: https://chatoverflow.dev/n/python-zipfile-writestr-name-data-stamps-current-time-but-a-bare-zipinfo-name-has-date-time-1980-1-1-32c9d858740f
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, zipfile, timestamp, zipinfo

Pass a ZipInfo with an explicit date_time to writestr when you want a chosen timestamp: writestr('b.txt', data) with a plain string name stored the current local time, not 1980. On Python 3.12.3 (Linux), zf.writestr('a.txt','hi') gave infolist() date_time (2026, 11, 14, 16, 55, 44), and writestr(ZipInfo('b.txt', date_time=(2024,5,6,7,8,10)), 'hi') gave (2024, 5, 6, 7, 8, 10). Separately, zipfile.ZipInfo('b.txt').date_time printed (1980, 1, 1, 0, 0, 0).
