Skip to content

Instantly share code, notes, and snippets.

@sk22
Last active January 12, 2026 22:40
Show Gist options
  • Select an option

  • Save sk22/b80b995867f7a9cb95b5279a62296b7e to your computer and use it in GitHub Desktop.

Select an option

Save sk22/b80b995867f7a9cb95b5279a62296b7e to your computer and use it in GitHub Desktop.
note to self: how to find immich localDateTime not matching the folder
// uses local timezone
function dateString(date) {
const time = date.toTimeString().slice(0, 8)
const y = date.getFullYear()
const m = (date.getMonth() + 1).toString().padStart(2, '0')
const d = date.getDate().toString().padStart(2, '0')
return `${y}-${m}-${d}T${time}`
}
// convert unix timestamps to local datetime
function dates(timestampsLineSeparated) {
const result = timestampsLineSeparated
.split('\n')
.map(t => dateString(new Date(Number(t))))
console.log(result.join('\n'))
}
/*
> dates(`1366401582482
| 1366401680930
| 1366479535311
| 1366565924570
| 1366661177639
| 1366661257581
| 1366694838120
| 1367299714135
| 1367346903009`)
2013-04-19T21:59:42
2013-04-19T22:01:20
2013-04-20T19:38:55
2013-04-21T19:38:44
2013-04-22T22:06:17
2013-04-22T22:07:37
2013-04-23T07:27:18
2013-04-30T07:28:34
2013-04-30T20:35:03
*/
-- sudo docker exec -i immich_postgres psql --dbname=immich --username=postgres
select to_char("localDateTime", 'YYYY') from asset limit 1;
-- -> '2019'
-- works for my directory structure: /volume1/photos/YYYY/...
select "originalPath" from asset where substring("originalPath" from 17 for 4) = '2018';
-- -> all files under /volume1/photos/2018/
select "id", "originalPath" from asset where substring("originalPath" from 17 for 4) <> to_char("localDateTime", 'YYYY') order by "originalPath";
-- -> files where /volume1/photos/YYYY doesn't match the localDateTime year
-- to refresh metadata:
-- POST https://photos.dat.i234.me/api/assets/jobs
-- x-api-key: …
-- body: { "name": "refresh-metadata", "assetIds": […] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment