Date's -j and -f flags can be used together to specify a date, in an arbitrary format, to convert it to a different format. The man page gives % date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s" as an example to convert a string in date's usual output format to an epoch timestamp. If the -j and -f flags are used without specifying all components of struct tm the unspecified components keep their current values: % date -j -f %Y-%m-%d 2021-09-30 +%s; sleep 5; date -j -f %Y-%m-%d 2021-09-30 +%s 1633047180 1633047185 This is behaviour is surprising; it's useful for -f alone (the user might want to change the time but leave the date alone, for example), but seems like -j should start with all components zeroed.
A commit references this bug: Author: emaste Date: Wed Aug 26 00:31:59 UTC 2020 New revision: 364790 URL: https://svnweb.freebsd.org/changeset/base/364790 Log: date.1: note possibly surprising behaviour of -j -f PR: 248918 MFC after: 1 week Sponsored by: The FreeBSD Foundation Changes: head/bin/date/date.1
A commit references this bug: Author: emaste Date: Wed Sep 2 17:46:56 UTC 2020 New revision: 365263 URL: https://svnweb.freebsd.org/changeset/base/365263 Log: MFC r364790: date.1: note possibly surprising behaviour of -j -f PR: 248918 Changes: _U stable/12/ stable/12/bin/date/date.1
^Triage: assign to committer that resolved.
Reopen: the oddity is now noted in the man page, but we should fix the surprising behaviour