Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert string to date

Posted on 2008-10-11
3
Medium Priority
?
2,212 Views
Last Modified: 2010-05-18
Hi all,

how do i convert user input (which i assume the example below is as string ) to unix date format?

echo "please enter date [dd/mm/yy]:
read answer

I can't use date -d option as my unix is sun solaris n does not support that.
It only supports

date [-u] mmddHHMM[[cc]yy][.SS]
 date [-u] [+format]
 date -a [-]sss[.fff]

any idea?



0
Comment
Question by:c00kie88
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 375 total points
ID: 22693757
you can get rid of / in the input string using

echo $answer | awk -F'/' '{ print $1 " "  $2 " "  $3 }' | read d m y

then

date $m$d0000$y

 
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22693962
Why given grade B?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22695141
Was your intention to reset the system date/time?  I got the impression you were simply trying to convert one date format to another.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question