1

i need some help to convert date into a string

i have an sql database running on my unix box which stores the date in str eg:1371509465

i would like to run a query to find if any future dates exist in the database

is there an equivalent function to php's strtotime in shell ?

David J. Liszewski
  • 10,959
  • 6
  • 44
  • 57
user2280769
  • 210
  • 4
  • 13

2 Answers2

3

Linux:

date --date='@1371509465'

Mac OS/X:

date -r 1371509465

perl:

perl -e "print scalar localtime(1371509465);"
Sam Ruby
  • 4,270
  • 22
  • 21
  • I think i found the answer is to have GNU core utilities installed. is there any other way to convert it to timestamp without having to install core utilities ?? – user2280769 May 03 '13 at 01:27
  • I don't know about SunOS. Do you have Perl installed? Or another language? – Sam Ruby May 03 '13 at 01:47
  • I do know about SunOS: up to v 5.10 (solaris 10) - use perl or install GNU coreutils. Solaris 11 has GNU coreutils as a package. IT may already be there. – jim mcnamara May 03 '13 at 03:14
1

found a way of doing that on solaris date

truss /usr/bin/date 2>&1 | grep time | awk -F" = " '{print $3}'

user2280769
  • 210
  • 4
  • 13