converting unix date variable to gmt

Hi,
I have a ksh script which extracts files from a directory in the following format, eg:
10288.Job.rescheduled.1154647335

I need to extract the unix timestamp (eg 1154647335) and convert it to dd-mm-yyyy.

Can anyone suggest anything for this?

thanks. :confused:

This should give you more information about it.

$ man localtime

I'm not sure if there's a standard utility for converting long -> date format.

If you have perl installed, this should do the trick:

$ cat x.pl
#!/usr/bin/env perl

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( 1154647335 );
$year+=1900; $mon++;

printf "%02d-%02d-%04d\n" , $mday , $mon , $year;


$ x.pl
03-08-2006

Thanks for the reply. Perl must be installed, but wondering how I would call this from the Korn shell script?

$ cat x.sh
x=$(./x.pl)
print Shell script says $x

$ ./x.sh
Shell script says 04-08-2006

Hi,
If this can help you

!/bin/bash
echo ' select left(from_unixtime(1154647335),10) "" ;' > time.txt 
mysql -u root -p "your_Pwd" <  time.txt

it is using from_unixtime function of Mysql to change ur unix timestamp in to date format u require. i have used left to extract date as it returns time also.

if you're under Solaris:

echo '0t1154647335=Y' | /usr/bin/adb

unfortunately I don't have mysql or solaris installed on the server. :frowning: