user2280769
user2280769

Reputation: 210

How to convert date to string in unix shell

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 ?

Upvotes: 1

Views: 4159

Answers (2)

user2280769
user2280769

Reputation: 210

found a way of doing that on solaris date

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

Upvotes: 1

Sam Ruby
Sam Ruby

Reputation: 4340

Linux:

date --date='@1371509465'

Mac OS/X:

date -r 1371509465

perl:

perl -e "print scalar localtime(1371509465);"

Upvotes: 3

Related Questions