Strtotime for Emacs Lisp

Is there any functionality in Emacs Lisp that behaves similarly to the PHP strtotime function ? (In fact, AFAIK implements the relative elements of the GNU date input formats .)

In PHP I can write

 echo strtotime("+2 months"); //1258891352 echo strtotime("-3 months +2 weeks"); //1246952239 

which return the appropriate UNIX timestamps.

+4
source share
3 answers

While not quite what you are asking for, this can be helpful. There is the command 'org-schedule in the org-mode package, which has a really nice interface for selecting dates. The special command that does this is 'org-read-date , which understands many ways to represent a date, including:

  +0 --> today . --> today +4d --> four days from today +4 --> same as above +2w --> two weeks from today ++5 --> five days from default date +2tue --> second Tuesday from now. 

If you are looking for an interactive way to specify dates using this syntactic sugar, this procedure should work well with the count. If you are looking for a software solution, it looks like the above command calls 'org-read-date-analyze to do the footwork. Note: its use is a bit obscure (two of its arguments are never defined ...), so if you can't figure it out right away, then maybe sending mail to the org mailing list is worth it.

+4
source
 (defun string-to-time (date) (shell-command-to-string (format "date --date='%s' +%%s" date))) 
+3
source

The closest inline function that I know of is coding time. If you want to use natural language, you probably have to write something like this: http://github.com/chaitanyagupta/chronicity

+1
source

All Articles