Hi, I am new to unix and I am doing following steps :
1. Ask user to enter date in mm-dd-yyyy format.
2. show the date user entered from step #1 .
3. convert user enter date into YYYY/MM/DD format.
Hi all,
I have used a bash script which ultimately converts a string into date using date --date option:
Code:
DATE=$DATE" "$TIME" "`date +%Y` //concatenating 2 strings
TMRW_DATE=`date --date="$DATE" +"%s"` //applying date command on string and getting the unixtime
Moderator's Comments:
I have this simple script which redirects the output and append it to a file.
filename="/home/ronnie/tmp/hello"
date=$(date)
echo "$date" >> $filename
Now, lets suppose I change date=$(date) to date= $(date) which will generate an error.
Given a date and time in a format that is not recognized by date, how can I get date to recognize the date and time?
For example:
$ date -d "09SEP2012:23:58:46"
date: invalid date `09SEP2012:23:58:46'
$ date -d "09SEP2012:23:58:46" --magic-option "ddMMMYYY:hh:mm:ss"
Sun Sep 9 23:58:46 MDT 2012
Does --magic-option exist?
I want to know the appropriate way of reading date from terminal and comparing with current date using shell script,
I have the below script,
a=`date +%Y-%m-%d`
while [ 1 ] ; do
echo "Enter Date"
read todate
if [ $todate < $a ];then
break;
fi
echo "todate greater than curDate"
done
it is not running as expected.
I'm trying to display a specific date in unix, using the date command, I can't figure out how to display a date other than today's date.
For example, if I was trying to display "July 4, 2011"
I use $date +"%B %d, %Y"
But I keep getting today's date in that format. How can I change it so that it displays the date I want?
Thanks.
How can I convert any user inputted date into yyyy/mm/dd?
For example user can input date in one of the following formats 20120121 , 2012-01-21, 01/21/2012, 01/21/2012 etc.
But I need to convert any of the date entered by user into yyyy/mm/dd (2012/01/2012). How?
This is the script I was using , but it is not working.
echo "Please enter the date: "
read X
a=$X+"%y/%m/%d"
echo $a
All, I am facing an issue with julian date conversion..
current command:
Code:
echo `date +%Y%j` `cat -n /home/user/FILENAME.dat |awk '{printf "%08s", $2}'`
The above command is working good. But in the above bolded part, it is converting system date to julian date.
How can I convert any user inputted date into yyyy/mm/dd ?
For example user can input date one of the following 20120121 , 2012-01-21 ,01/21/2012,01/21/2012 etc
But I need to convert any of the date entered by user into yyyy/mm/dd (2012/01/2012). Any suggestion.