Re: Parse Unix date !

[email protected] ("Chas. Owens")
Newsgroups perl.beginners
Message-ID <[email protected]>
On Thu, May 29, 2008 at 7:42 AM, AY <[email protected]> wrote:
> I'm required to grab some value from table in sybase based on the
> timestamp of the file generated in Unix ( solaris ). Time format in
> Sybase is say ( Mar 22 2008 10:41:59:662 AM).
>
> I'm able to format the time stamp of the file in this format ( Mar 22
> 2008 10:41:59 AM) but not the *milliseconds*.
>
> 1) Would 'ctime' or 'atime' or 'mtime' return milliseconds as well?

I don't believe so.  IIRC, ctime, atime, and mtime are all based on
the number of seconds since the epoch (1970-01-01 00:00:00)

>
> 2) If it does how can we Parse the milliseconds?
>
> If I remember right I do something like
> UnixDate(ParseDate($fileTimeStamp), "% % %") etc..
>
> I'm not sure what  %??   to be used inorder to get *milliseconds*.

You could use

my $d = UnixDate(ParseDate($fileTimeStamp), "%b %d %Y %I:%M:%S:000 %p")

but I (being an old C person) would say

use POSIX qw/strftime/;

my $d = strftime "%b %d %Y %I:%M:%S:000 %p", localtime $timestamp;


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.