* Get current date and time as a string? @ 2024-05-22 11:22 Dr Rainer Woitok 2024-05-22 11:29 ` Emanuel Berg ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Dr Rainer Woitok @ 2024-05-22 11:22 UTC (permalink / raw) To: Help-Gnu-Emacs Greetings, after having unsuccessfully used "C-h a" to find a command returning the current date and time (preferably as "YYYY-MM-DDThh:mm:ss") I'm now ask- ing the combined wisdom of this list: is there such a thing? Sincerely, Rainer ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:22 Get current date and time as a string? Dr Rainer Woitok @ 2024-05-22 11:29 ` Emanuel Berg 2024-05-22 11:30 ` Joost Kremers 2024-05-22 18:18 ` Pierre Rouleau 2 siblings, 0 replies; 8+ messages in thread From: Emanuel Berg @ 2024-05-22 11:29 UTC (permalink / raw) To: help-gnu-emacs Dr Rainer Woitok wrote: > after having unsuccessfully used "C-h a" to find a command > returning the current date and time (preferably as > "YYYY-MM-DDThh:mm:ss") (format-time-string "%FT%T") -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:22 Get current date and time as a string? Dr Rainer Woitok 2024-05-22 11:29 ` Emanuel Berg @ 2024-05-22 11:30 ` Joost Kremers 2024-05-22 11:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor 2024-05-22 16:27 ` tpeplt 2024-05-22 18:18 ` Pierre Rouleau 2 siblings, 2 replies; 8+ messages in thread From: Joost Kremers @ 2024-05-22 11:30 UTC (permalink / raw) To: Dr Rainer Woitok; +Cc: Help-Gnu-Emacs On Wed, May 22 2024, Dr Rainer Woitok wrote: > Greetings, > > after having unsuccessfully used "C-h a" to find a command returning the > current date and time (preferably as "YYYY-MM-DDThh:mm:ss") I'm now ask- > ing the combined wisdom of this list: is there such a thing? You'll want a combination of `current-time` and `format-time-string`. See (info "(elisp) Time of Day") and (info "(elisp) Time Parsing"), respectively. HTH -- Joost Kremers Life has its moments ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:30 ` Joost Kremers @ 2024-05-22 11:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor 2024-05-22 11:59 ` Joost Kremers 2024-05-22 16:27 ` tpeplt 1 sibling, 1 reply; 8+ messages in thread From: Michael Heerdegen via Users list for the GNU Emacs text editor @ 2024-05-22 11:52 UTC (permalink / raw) To: help-gnu-emacs Joost Kremers <joostkremers@fastmail.fm> writes: > You'll want a combination of `current-time` and > `format-time-string`. See (info "(elisp) Time of Day") and (info > "(elisp) Time Parsing"), respectively. Or `current-time-string'. Michael. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor @ 2024-05-22 11:59 ` Joost Kremers 0 siblings, 0 replies; 8+ messages in thread From: Joost Kremers @ 2024-05-22 11:59 UTC (permalink / raw) To: Michael Heerdegen via Users list for the GNU Emacs text editor Cc: Michael Heerdegen On Wed, May 22 2024, Michael Heerdegen via Users list for the GNU Emacs text editor wrote: > Joost Kremers <joostkremers@fastmail.fm> writes: > >> You'll want a combination of `current-time` and >> `format-time-string`. See (info "(elisp) Time of Day") and (info >> "(elisp) Time Parsing"), respectively. > > Or `current-time-string'. Possibly, but IIUC it won't give you the time in the format that the OP is looking for. -- Joost Kremers Life has its moments ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:30 ` Joost Kremers 2024-05-22 11:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor @ 2024-05-22 16:27 ` tpeplt 1 sibling, 0 replies; 8+ messages in thread From: tpeplt @ 2024-05-22 16:27 UTC (permalink / raw) To: Dr Rainer Woitok; +Cc: Help-Gnu-Emacs >> On Wed, May 22 2024, Dr Rainer Woitok wrote: >> Greetings, >> >> after having unsuccessfully used "C-h a" to find a command returning the >> current date and time (preferably as "YYYY-MM-DDThh:mm:ss") I'm now ask- >> ing the combined wisdom of this list: is there such a thing? > > You'll want a combination of `current-time` and `format-time-string`. See (info > "(elisp) Time of Day") and (info "(elisp) Time Parsing"), respectively. > Also, for future reference, try "C-h a" and enter "apropos" at the prompt. This will show the many other forms of looking up appropriate information, including ‘apropos-function’. So, instead of looking up commands (interactive functions), look up functions (commands, functions, macros) related to time: M-x apropos-function Search for function (word list or regexp): time RET And since it accepts regular expressions, you can narrow this search to eliminate names that include, for example, "timer": Search for function (word list or regexp): -time$\|^time-\|-time- -- The lyf so short, the craft so long to lerne. - Geoffrey Chaucer, The Parliament of Birds. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 11:22 Get current date and time as a string? Dr Rainer Woitok 2024-05-22 11:29 ` Emanuel Berg 2024-05-22 11:30 ` Joost Kremers @ 2024-05-22 18:18 ` Pierre Rouleau 2024-05-23 0:34 ` Emanuel Berg 2 siblings, 1 reply; 8+ messages in thread From: Pierre Rouleau @ 2024-05-22 18:18 UTC (permalink / raw) To: Dr Rainer Woitok; +Cc: Help-Gnu-Emacs The function you are looking for is `format-time-string'. Get help on it with ``C-h f format-time-string`` Use ielm (the Elisp shell) to experiment while the help is shown inside another buffer. *** Welcome to IELM *** Type (describe-mode) or press C-h m for help. ELISP> (format-time-string "%Y-%m-%d") "2024-05-22" ELISP> (format-time-string "%Y-%m-%dT%H:%M:%S") "2024-05-22T14:15:11" ELISP> Hope this helps On Wed, May 22, 2024 at 7:23 AM Dr Rainer Woitok <rainer.woitok@gmail.com> wrote: > Greetings, > > after having unsuccessfully used "C-h a" to find a command returning the > current date and time (preferably as "YYYY-MM-DDThh:mm:ss") I'm now ask- > ing the combined wisdom of this list: is there such a thing? > > Sincerely, > Rainer > > -- /Pierre ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Get current date and time as a string? 2024-05-22 18:18 ` Pierre Rouleau @ 2024-05-23 0:34 ` Emanuel Berg 0 siblings, 0 replies; 8+ messages in thread From: Emanuel Berg @ 2024-05-23 0:34 UTC (permalink / raw) To: help-gnu-emacs Pierre Rouleau wrote: > The function you are looking for is `format-time-string'. > Get help on it with ``C-h f format-time-string`` > > Use ielm (the Elisp shell) to experiment while the help is > shown inside another buffer. > > *** Welcome to IELM *** Type (describe-mode) or press C-h m for help. > ELISP> (format-time-string "%Y-%m-%d") > "2024-05-22" > ELISP> (format-time-string "%Y-%m-%dT%H:%M:%S") > "2024-05-22T14:15:11" Close but no cigar :) (format-time-string "%FT%T") ; 2024-05-23T02:32:40 -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-23 0:34 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-05-22 11:22 Get current date and time as a string? Dr Rainer Woitok 2024-05-22 11:29 ` Emanuel Berg 2024-05-22 11:30 ` Joost Kremers 2024-05-22 11:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor 2024-05-22 11:59 ` Joost Kremers 2024-05-22 16:27 ` tpeplt 2024-05-22 18:18 ` Pierre Rouleau 2024-05-23 0:34 ` Emanuel Berg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).