Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert string to date

Posted on 2008-10-11
3
Medium Priority
?
2,176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

715 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