Get timestamp with millisecond precision

Hi All,

could any body let me know.
how to get timestamp with millisecond precision in unix bash shell.
example -->2005-12-06- 4-22-35-195

please help me.

Thanks,
Krupa:wall:

If you have Linux:

date --rfc-3339=ns
date +%Y-%m-%d:%H:%M:%S.%N

gives nanosecond accuracy, you can truncate the value to ms if you want.

Hi,
I am getting below error

[csdwmast@ucdoud01]:../to_be_loaded>`date +%Y-%m-%d:%H:%M:%S.%N`
ksh: 2012-06-06:10:18:01.%N:  not found

Thanks,
Krupa

---------- Post updated at 11:50 PM ---------- Previous update was at 09:20 AM ----------

Hi Jim,

when i am using this command in unix prompt.

`date +%Y-%m-%d:%H:%M:%S.%N`

I am getting blow error.

ksh: 2012-06-06:10:18:01.%N: not found

please help me regarding this.

Thanks,
Krupa

$ perl -le 'use POSIX 'strftime'; use Time::HiRes 'gettimeofday'; ($x,$y)=gettimeofday; $y=sprintf("%03d",$y/1000);print strftime("%Y-%m-%d %H:%M:%S",localtime($x)),".$y"'
2012-06-07 06:07:06.002
$