music
OSdata.com: programming text book 

OSdata.com

date

summary

    This subchapter looks at date, a UNIX (and Linux) command.

    date is used to set or view the system date and time.

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

date

    This subchapter looks at date, a UNIX (and Linux) command.

    date is used to set or view the system date and time.

    $ date
    Mon Sep  3 00:56:17 PDT 2012
    $

    The format for the output is: day of the week, month, day of the month, 24 hour time, time zone, year.

formatted output

    Display the time and/or date with formatting by including formatting options (which can be used to set variables to a specific format).

    $ date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'
    DATE: 11/23/13
    TIME: 22:12:19
    $

    Setting a variable with the current date:

    $ NOW=$(date +"%m/%d/%Y")
    $ echo $NOW
    11/23/2013
    $

Format specifiers (format string starts with +)
Specifier Description Values or example
Day
%a weekday, abbreviated Sun
%A weekday, full Sunday
%d day of the month, two digits, zero filled 08
%e day of the month 8
%j day of year, zero filled 001Ð366
%u day of week from Monday to Sunday 1Ð7
%w day of week from Sunday to Saturday 0Ð6
Week
%U week number, Sunday as first day of week 00Ð53
%W week number, Monday as first day of week 00Ð53
%V ISO standard week of the year 01Ð53
Month
%m two-digit month number 01Ð12
%h month name, abbreviated Nov
%b month name, localised abbreviation Nov
%B locale's full month, variable length November
Year
%y two-digit year 00Ð99
%Y four-digit year 2013
%g two-digit year corresponding to the %V week number
%G four-digit year corresponding to the %V week number
Century
%C two century digits from year 00Ð99
Date
%D mm/dd/yy 11/24/13
%x locale's date representation 11/24/2013
%F %Y-%m-%d 2013-11-24
Hours
%l hour (12 hour) 4
%I hour (12 hour), zero-filled 04
%k hour (24 hour) 4
%H hour (24 hour), zero-padded 04
%p locale's upper case AM or PM (blank in many locales) AM
%P locale's lower case am or pm am
Minutes
%M two-digit minute number 05
Seconds
%s seconds since 00:00:00 1970-01-01 UTC (Unix epoch) 1385265929
%S two-digit second number 00Ð60 (Includes 60 to accommodate a leap second)
%N nanoseconds 000000000Ð999999999
Time
%r hours, minutes, seconds (12-hour clock) 04:05:29 AM
%R hours, minutes (24 hour clock) 04:05
%T hours, minutes, seconds (24-hour clock) 04:05:29
%X locale's time representation 11:07:26 AM
Date and time
%c locale's date and time Sat Nov 04 12:02:33 EST 1989
Time zone
%z RFC-822 style numeric time zone -0500
%Z time zone name; nothing if no time zone is determinable EST, EDT

literals:      %n newline      %% percent      %t horizontal tab

    By default, date normally fills numeric fields with zeroes. GNU date, but not BSD date, recognizes a modifier between the per cent sign (%) and the format specifier:

    TZ Specifies the time zone, unless overridden by command line parameters. If neither is specified, the setting from /etc/localtime is used.

setting time and date

    Only the root or superuser an set the system date and time. In Mac OS X, you can use the clock system preferences t set the time and date. In Ubuntu-based Linux, you can click on the clock and select Time and Date settings from the menu or click on the System menu, select Adminsitration, select Time and Date.

    Set the time to noon:

    $ date 1200
    $

    Set the time to 3:30:30 a.m.:

    $ date 0330.30
    $

    Set the date to October 31st (Halloween) at 3:30 a.m.:

    $ date 10310330
    $

other

    On November 8, 2010, Ramesh Natarajan named this the number 49 most frequently used UNIX/Linux command at this web page 50 Most Frequently Used UNIX / Linux Commands (With Examples).


comments, suggestions, corrections, criticisms

please contact us

your name:
email address:
phone number:
message:

free music player coding example

    Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

    View music player in action: www.musicinpublic.com/.

    Create your own copy from the original source code/ (presented for learning programming).


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

view text book
HTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

previous page next page
previous page next page

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2012, 2013 Milo

    Created: February 28, 2012

    Last Updated: November 23, 2013


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

previous page next page
previous page next page