Tuesday, June 14, 2011

Chaneg Date and Time Linux

============ Treating with date command =================
1> date 081811002007 [mmddhhmmyyyy]--To set the Linux clock to 11th-Aug-2007-11-AM
2> timeconfig --Set your TIMEZONE
3> hwclock --hc to sys--->-->To set the Linux[system]clock from the HW clock
4> hwclock --utc sys to hc -->To set the HWclock from the Linux[system] clock

touch -t yyyymmddhhmm filename

echo "DATE:" `date --date "today" +%d-%m-%Y`             <--DATE:20-12-2010
echo "DATE:" `date --date "yesterday" +%d-%m-%Y`
echo "DATE:" `date --date "+5 minutes ago" +%d-%m-%Y-%M` <--present  -5 min
echo "DATE:" `date --date "-5minutes ago" +%d-%m-%Y-%M`  <---Present +5 min
echo "DATE:" `date --date "1 month ago -5 minutes ago" +%d-%m-%Y-%M`
                                                         <--present -1 month +5 min

Some importnat journal use paramiters
%a  --> Mon
%b  --> Jan
%d  --> date 01..31      %e  --> 1..31
%H  --> hour 0..23)      %k  --> 1..23
%M  --> minute (00..59)
%S  --> Seconds(00..60)
%I  --> hour 00..12)     %m  --> 1-12
%Y  --> year 2010        %y  --> year 10(last 2 digit)
%p  --> AM-PM            %p  --> am-pm
%T  --> %H:%M:%S

=================================== More n more ==================
%%--->a literal %
%a--->localeâs abbreviated weekday name (e.g., Sun)
%A--->localeâs full weekday name (e.g., Sunday)
%b--->localeâs abbreviated month name (e.g., Jan)
%B--->localeâs full month name (e.g., January)
%c--->localeâs date and time (e.g., Thu Mar  3 23:05:25 2005)
%C--->century; like %Y, except omit last two digits (e.g., 21)
%d--->day of month (e.g, 01)
%D--->date; same as %m/%d/%y
%e--->day of month, space padded; same as %_d
%F--->full date; same as %Y-%m-%d
%g--->last two digits of year of ISO week number (see %G)
%G--->year of ISO week number (see %V); normally useful only with %V
%h--->same as %b
%H--->hour (00..23)
%I--->hour (01..12)
%j--->day of year (001..366)
%k--->hour ( 0..23)
%l--->hour ( 1..12)
%m--->month (01..12)
%M--->minute (00..59)
%n--->a newline
%N--->nanoseconds (000000000..999999999)
%p--->localeâs equivalent of either AM or PM; blank if not known
%P--->like %p, but lower case
%r--->localeâs 12-hour clock time (e.g., 11:11:04 PM)
%R--->24-hour hour and minute; same as %H:%M
%s--->seconds since 1970-01-01 00:00:00 UTC
%S--->second (00..60)
%t--->a tab
%T--->time; same as %H:%M:%S
%u--->day of week (1..7); 1 is Monday
%U--->week number of year, with Sunday as first day of week (00..53)
%V--->ISO week number, with Monday as first day of week (01..53)
%w--->day of week (0..6); 0 is Sunday
%W--->week number of year, with Monday as first day of week (00..53)
%x--->localeâs date representation (e.g., 12/31/99)
%X--->localeâs time representation (e.g., 23:13:48)
%y--->last two digits of year (00..99)
%Y--->year
%z--->+hhmm numeric timezone (e.g., -0400)
%:z   -> +hh:mm numeric timezone (e.g., -04:00)
%::z  -> +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z -> numeric time zone with : to necessary precision (e.g., -04, +05:30)
%Z    -> alphabetic time zone abbreviation (e.g., EDT)