unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to insert a timestamp?
@ 2004-01-06 21:12 '
  2004-01-06 21:16 ` Benjamin Rutt
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: ' @ 2004-01-06 21:12 UTC (permalink / raw)


How can I insert a string representing the current time/date at the
point?  It is for timestamping entries in a diary/log.

Adam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a timestamp?
  2004-01-06 21:12 how to insert a timestamp? '
@ 2004-01-06 21:16 ` Benjamin Rutt
  2004-01-08  7:43   ` '
  2004-01-07  6:14 ` WANG Wei
  2004-01-07 12:59 ` Bruce Ingalls
  2 siblings, 1 reply; 5+ messages in thread
From: Benjamin Rutt @ 2004-01-06 21:16 UTC (permalink / raw)


ack94598@yahoo.com (') writes:

> How can I insert a string representing the current time/date at the
> point?  It is for timestamping entries in a diary/log.

I use:

(insert (format-time-string "%a %b %e, %Y %l:%M %p"))

which gives (ATM):  Tue Jan  6, 2004  4:15 PM

There are a zillion other ways to do it.  See C-h f
format-time-string.
-- 
Benjamin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a timestamp?
  2004-01-06 21:12 how to insert a timestamp? '
  2004-01-06 21:16 ` Benjamin Rutt
@ 2004-01-07  6:14 ` WANG Wei
  2004-01-07 12:59 ` Bruce Ingalls
  2 siblings, 0 replies; 5+ messages in thread
From: WANG Wei @ 2004-01-07  6:14 UTC (permalink / raw)



try

(insert-string (current-time-string))

> ack94598@yahoo.com (') writes:

> How can I insert a string representing the current time/date at the
> point?  It is for timestamping entries in a diary/log.
> 
> Adam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a timestamp?
  2004-01-06 21:12 how to insert a timestamp? '
  2004-01-06 21:16 ` Benjamin Rutt
  2004-01-07  6:14 ` WANG Wei
@ 2004-01-07 12:59 ` Bruce Ingalls
  2 siblings, 0 replies; 5+ messages in thread
From: Bruce Ingalls @ 2004-01-07 12:59 UTC (permalink / raw)


> How can I insert a string representing the current time/date at the
> point?  It is for timestamping entries in a diary/log.
> Adam

Alternately, try
	(add-change-log-entry nil buffer-file-name)
replacing buffer-file-name with the actual file name

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to insert a timestamp?
  2004-01-06 21:16 ` Benjamin Rutt
@ 2004-01-08  7:43   ` '
  0 siblings, 0 replies; 5+ messages in thread
From: ' @ 2004-01-08  7:43 UTC (permalink / raw)


Thanks for your help!  I had never actually written an Emacs Lisp
function before, but with this handy link:

http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/index.html

I was able to quickly produce the following:

(defun timestamp ()
  "Insert timestamp at point."
  (interactive)
  (insert (format-time-string "%a, %d %b %Y %H:%M:%S %z")))

(global-set-key [f5] 'timestamp)

I love it!  Emacs rocks!

Adam

Benjamin Rutt <brutt+news@bloomington.in.us> wrote in message news:<wc365ford5w.fsf@mu.cis.ohio-state.edu>...
> ack94598@yahoo.com (') writes:
> 
> > How can I insert a string representing the current time/date at the
> > point?  It is for timestamping entries in a diary/log.
> 
> I use:
> 
> (insert (format-time-string "%a %b %e, %Y %l:%M %p"))
> 
> which gives (ATM):  Tue Jan  6, 2004  4:15 PM
> 
> There are a zillion other ways to do it.  See C-h f
> format-time-string.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-08  7:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-06 21:12 how to insert a timestamp? '
2004-01-06 21:16 ` Benjamin Rutt
2004-01-08  7:43   ` '
2004-01-07  6:14 ` WANG Wei
2004-01-07 12:59 ` Bruce Ingalls

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).