SliTaz SliTaz Forum

You are not logged in.

#1 2014-01-31 18:22:33

emgi
Member
Registered: 2012-12-17
Posts: 127

Working with date

Recently I found an elegant way to use simple scripting to calculate & output a date which is not "now".

It utilizes the linux date command, a program which is much more versatile than is generally known.

$ date +%s can be used to output the current date in seconds.

This outputs a number like: 1391191922 representing the current time in seconds.

This number can be manipulated to add or substract a certain amount of time (also in seconds).

My case was using a known number of minutes to calculate a time in the future.

I used a perlscript to do the calculations but you can use whatever you like.

The result is another number which can be fed to the date command like this:

$ date -d @1391662381

Or, from a file:

$ date -d @$(cat /home/books/datecompleted)

Thu Feb  6 05:53:01 CET 2014

$

/emgi

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.017 seconds, 7 queries executed - Memory usage: 1.52 MiB (Peak: 1.77 MiB) ]