Solved

Convert string to date

Posted on 2008-10-11
3
1,930 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 125 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

770 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