How to translate a date

Here you can discuss every aspect of Debian. Note: not for support requests!

How to translate a date

Postby xerxesdebian » 2006-05-26 22:20

Is it possible by console command to translate a number given as number (eg:1148581788) human redable format eg: Sat May 27 01:13:23 EEST 2006

Or should I write a program as I did for windows ? (As Im newbie in Linux C will kill me)

Anybody can help me ?
Posts: 3
Joined: 2006-05-26 16:49

Postby Grifter » 2006-05-27 14:34

if you run the command uptime, i think it extrapolates it from the output of /proc/uptime (cat /proc/uptime), you could download the source for the procps package and go thru the source of the uptime command for inspiration if you want to make your own (:
Eagles may soar, but weasels don't get sucked into jet engines...
Posts: 1572
Joined: 2006-05-04 07:53
Location: Svea Rike

Postby ajdlinux » 2006-05-27 21:53

You can do it in Perl AFAIK, but then again noone wants to program in Perl ;)
Posts: 2480
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

Postby lacek » 2006-05-28 16:04

Of course everyone loves perl... :-D

You can do it like this:
Code: Select all

use POSIX qw(strftime);

$format="%Y.%m.%d %H:%M:%S";

if ($ARGV[1]) {

if ($ARGV[0]) {

print strftime "$format\n", localtime $time;

This code will print the given time in the given format. If you save it as a script, the first argument of it is the time in seconds, and the second is the format.
Moderator Team Member
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 17 guests