all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregor Zattler <telegraph@gmx.net>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: a command to insert today's date OR time (or both)?
Date: Sun, 9 Jan 2011 13:06:41 +0100	[thread overview]
Message-ID: <20110109120641.GA10013@shi.workgroup> (raw)
In-Reply-To: <871v4m92k8.fsf@kuiper.lan.informatimago.com>

Hi Pascal,
* Pascal J. Bourguignon <pjb@informatimago.com> [09. Jan. 2011]:
> dkcombs@panix.com (David Combs) writes:
> 
>> I've looked in emacs' *info*, its list of commands, etc,
>> and can find nothing.
> 
> C-u M-! date RET
> Sun Jan  9 04:29:12 CET 2011
> 
> C-u M-: (calendar-current-date) RET
> (1 9 2011)
> 
>> Sure would be nice to be to easily to insert the current
>> date, time, or both.
> 
> Then write the command to do so.
> Notice how each user will want to insert it in a different format.

Stolen from some website:

(defun insert-date (prefix)
  "Insert the current date. With prefix-argument, use ISO format. With
   two prefix arguments, write out the day and month name.  With
   three (!) prefix arguments give date and time in ISO Format
   and append day and month name in brackets"
    (interactive "P")
    (let ((format (cond
                   ((not prefix) "%d.%m.%Y")
                   ((equal prefix '(4)) "%Y-%m-%d")
                   ((equal prefix '(16)) "%A, %d. %B %Y")))
          (system-time-locale "de_DE"))
      (insert (format-time-string format))))

(global-set-key (kbd "C-c d") 'insert-date)

 

Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-



  reply	other threads:[~2011-01-09 12:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-09  1:00 a command to insert today's date OR time (or both)? David Combs
2011-01-09  3:30 ` Pascal J. Bourguignon
2011-01-09 12:06   ` Gregor Zattler [this message]
2011-01-09  5:19 ` Udyant Wig
2011-01-09  5:30   ` Udyant Wig
2011-01-09 14:23   ` Drew Adams
2011-01-09 14:32 ` Drew Adams
2011-01-09 14:42   ` Le Wang
     [not found]   ` <mailman.18.1294584142.18702.help-gnu-emacs@gnu.org>
2011-01-21  1:33     ` David Combs
2011-01-21 11:36       ` ken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110109120641.GA10013@shi.workgroup \
    --to=telegraph@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.