\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Matthew Perryman (PezMat)} \pdfinfo{ /Title (date-time-formats.pdf) /Creator (Cheatography) /Author (Matthew Perryman (PezMat)) /Subject (Date/Time Formats Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A9D08E} \definecolor{LightBackground}{HTML}{F4F9F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Date/Time Formats Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Matthew Perryman (PezMat)} via \textcolor{DarkBackground}{\uline{cheatography.com/26431/cs/7970/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Matthew Perryman (PezMat) \\ \uline{cheatography.com/pezmat} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 27th April, 2016.\\ Updated 8th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{x{4.4902 cm} x{12.7798 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Predefined Date/Time Formats}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{R}} or {\bf{r}} & Formats the date according to the RFC1123Pattern property.\{\{nl\}\}For example, {\bf{Sun, 02 Mar 2008 16:07:04 GMT}}\{\{nl\}\}The formatted date does not adjust the value of the date and time.\{\{nl\}\}You must adjust the Date/Time value to GMT before calling the Format function \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} {\bf{U}} & Formats the date and time with the long date and long time as GMT.\{\{nl\}\}For example, {\bf{02 March 2008 16:07:04}} \tn % Row Count 14 (+ 4) % Row 2 \SetRowColor{LightBackground} {\bf{F}} & Displays the Long Date and Long Time according to your current culture's format.\{\{nl\}\}For example, {\bf{02 March 2008 16:07:04}} \tn % Row Count 19 (+ 5) % Row 3 \SetRowColor{white} {\bf{f}} & Displays the Long Date and Short Time according to your current culture's format.\{\{nl\}\}For example, {\bf{02 March 2008 16:07}} \tn % Row Count 24 (+ 5) % Row 4 \SetRowColor{LightBackground} {\bf{G}} & General Date\{\{nl\}\}Displays a date and/or time.\{\{nl\}\}For example, {\bf{02/03/2008 16:07:04}}\{\{nl\}\}Date display is determined by your application's current culture value \tn % Row Count 30 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.4902 cm} x{12.7798 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Predefined Date/Time Formats (cont)}} \tn % Row 5 \SetRowColor{LightBackground} {\bf{g}} & Displays the Short Date and Short Time according to your current culture's format.\{\{nl\}\}For example, {\bf{02/03/2008 16:07}} \tn % Row Count 5 (+ 5) % Row 6 \SetRowColor{white} {\bf{D}} & Long Date\{\{nl\}\}Displays a date according to your current culture's Long Date format.\{\{nl\}\}For example, {\bf{02 March 2008}} \tn % Row Count 10 (+ 5) % Row 7 \SetRowColor{LightBackground} {\bf{d}} & Short Date\{\{nl\}\}Displays a date using your current culture's Short Date format.\{\{nl\}\}For example, {\bf{02/03/2008}} \tn % Row Count 14 (+ 4) % Row 8 \SetRowColor{white} {\bf{M}} or {\bf{m}} & Displays the month and the day of a date.\{\{nl\}\}For example, {\bf{02 March}} \tn % Row Count 17 (+ 3) % Row 9 \SetRowColor{LightBackground} {\bf{Y}} or {\bf{y}} & Formats the date as the year and month.\{\{nl\}\}For example, {\bf{March 2008}} \tn % Row Count 20 (+ 3) % Row 10 \SetRowColor{white} {\bf{T}} & Long Time\{\{nl\}\}Displays a time using your current culture's Long Time format; typically includes hours, minutes, seconds.\{\{nl\}\}For example, {\bf{16:07:04}} \tn % Row Count 26 (+ 6) % Row 11 \SetRowColor{LightBackground} {\bf{t}} & Short Time\{\{nl\}\}Displays a time using your current culture's Short Time format.\{\{nl\}\}For example, {\bf{16:07}} \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.4902 cm} x{12.7798 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Predefined Date/Time Formats (cont)}} \tn % Row 12 \SetRowColor{LightBackground} {\bf{s}} & Formats the date and time as a sortable index.\{\{nl\}\}For example, {\bf{2008-03-02T16:07:04}} \tn % Row Count 4 (+ 4) % Row 13 \SetRowColor{white} {\bf{u}} & Formats the date and time as a GMT sortable index.\{\{nl\}\}For example, {\bf{2008-03-02 16:07:04Z}} \tn % Row Count 8 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{{\bf{The examples were created on a machine with 'English (United Kingdom)' Region settings}} \newline Uses {\bf{2nd of March 2008 16:07:04 GMT}} as the example Date \& Time} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{User-Defined Date/Time Formats}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{:}} & Time separator\{\{nl\}\}In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character that is used as the time separator in formatted output is determined by your application's current culture value. \tn % Row Count 10 (+ 10) % Row 1 \SetRowColor{white} {\bf{/}} & Date separator\{\{nl\}\}In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character that is used as the date separator in formatted output is determined by your application's current culture. \tn % Row Count 20 (+ 10) % Row 2 \SetRowColor{LightBackground} {\bf{\%}} & Used to indicate that the following character should be read as a single-letter format without regard to any trailing letters. Also used to indicate that a single-letter format is read as a user-defined format. See what follows for additional details \{\{fa-star\}\}. \tn % Row Count 28 (+ 8) % Row 3 \SetRowColor{white} {\bf{d}} & Displays the Day as a number without a leading zero\{\{nl\}\}For example, {\bf{2}}\{\{nl\}\}\{\{fa-star\}\}Use \%d if this is the only character in your user-defined numeric format. \tn % Row Count 33 (+ 5) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{User-Defined Date/Time Formats (cont)}} \tn % Row 4 \SetRowColor{LightBackground} {\bf{dd}} & Displays the Day as a number with a leading zero\{\{nl\}\}For example, {\bf{02}} \tn % Row Count 3 (+ 3) % Row 5 \SetRowColor{white} {\bf{ddd}} & Displays the Day as an abbreviation\{\{nl\}\}For example, {\bf{Sun}} \tn % Row Count 5 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{dddd}} & Displays the Day as a full name\{\{nl\}\}For example, {\bf{Sunday}} \tn % Row Count 7 (+ 2) % Row 7 \SetRowColor{white} {\bf{M}} & Displays the Month as a number without a leading zero\{\{nl\}\}For example, {\bf{3}}\{\{nl\}\}\{\{fa-star\}\}Use \%M if this is the only character in your user-defined numeric format. \tn % Row Count 13 (+ 6) % Row 8 \SetRowColor{LightBackground} {\bf{MM}} & Displays the Month as a number with a leading zero\{\{nl\}\}For example, {\bf{03}} \tn % Row Count 16 (+ 3) % Row 9 \SetRowColor{white} {\bf{MMM}} & Displays the Month as an abbreviation\{\{nl\}\}For example, {\bf{Mar}} \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{MMMM}} & Displays the Month as a full month name\{\{nl\}\}For example, {\bf{March}} \tn % Row Count 21 (+ 3) % Row 11 \SetRowColor{white} {\bf{y}} & Displays the Year as a number without leading zeros.\{\{nl\}\}For exmaple, {\bf{8}}\{\{nl\}\}\{\{fa-star\}\}Use \%y if this is the only character in your user-defined numeric format. \tn % Row Count 27 (+ 6) % Row 12 \SetRowColor{LightBackground} {\bf{yy}} & Displays the Year in two-digit numeric format with a leading zero, if applicable.\{\{nl\}\}For example, {\bf{08}} \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{User-Defined Date/Time Formats (cont)}} \tn % Row 13 \SetRowColor{LightBackground} {\bf{yyy}} & Displays the year in four-digit numeric format.\{\{nl\}\}For example, {\bf{2008}} \tn % Row Count 3 (+ 3) % Row 14 \SetRowColor{white} {\bf{yyyy}} & Displays the year in four-digit numeric format.\{\{nl\}\}For example, {\bf{2008}} \tn % Row Count 6 (+ 3) % Row 15 \SetRowColor{LightBackground} {\bf{gg}} & Displays the period/era string\{\{nl\}\}For example, {\bf{A.D.}} \tn % Row Count 8 (+ 2) % Row 16 \SetRowColor{white} {\bf{h}} & Displays the Hour as a number without leading zeros using the 12-hour clock\{\{nl\}\}For example, {\bf{4}}\{\{nl\}\}\{\{fa-star\}\}Use \%h if this is the only character in your user-defined numeric format. \tn % Row Count 14 (+ 6) % Row 17 \SetRowColor{LightBackground} {\bf{hh}} & Displays the Hour as a number with leading zeros using the 12-hour clock\{\{nl\}\}For example, {\bf{04}} \tn % Row Count 17 (+ 3) % Row 18 \SetRowColor{white} {\bf{H}} & Displays the Hour as a number without leading zeros using the 24-hour clock\{\{nl\}\}For example, {\bf{16}}\{\{nl\}\}\{\{fa-star\}\}Use \%H if this is the only character in your user-defined numeric format. \tn % Row Count 23 (+ 6) % Row 19 \SetRowColor{LightBackground} {\bf{HH}} & Displays the Hour as a number with leading zeros using the 24-hour clock\{\{nl\}\}For example, {\bf{16}} \tn % Row Count 26 (+ 3) % Row 20 \SetRowColor{white} {\bf{m}} & Displays the Minute as a number without leading zeros\{\{nl\}\}For example, {\bf{7}}\{\{nl\}\}\{\{fa-star\}\}Use \%m if this is the only character in your user-defined numeric format. \tn % Row Count 32 (+ 6) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{User-Defined Date/Time Formats (cont)}} \tn % Row 21 \SetRowColor{LightBackground} {\bf{mm}} & Displays the Minute as a number with leading zeros\{\{nl\}\}For example, {\bf{07}} \tn % Row Count 3 (+ 3) % Row 22 \SetRowColor{white} {\bf{s}} & Displays the Second as a number without leading zeros\{\{nl\}\}For example, {\bf{4}}\{\{nl\}\}\{\{fa-star\}\}Use \%s if this is the only character in your user-defined numeric format. \tn % Row Count 9 (+ 6) % Row 23 \SetRowColor{LightBackground} {\bf{ss}} & Displays the Second as a number with leading zeros\{\{nl\}\}For example, {\bf{04}} \tn % Row Count 12 (+ 3) % Row 24 \SetRowColor{white} {\bf{f}} & Displays fractions of seconds.\{\{nl\}\}For example ff displays hundredths of seconds, whereas ffff displays ten-thousandths of seconds. You may use up to seven f symbols in your user-defined format.\{\{nl\}\}\{\{fa-star\}\}Use \%f if this is the only character in your user-defined numeric format. \tn % Row Count 21 (+ 9) % Row 25 \SetRowColor{LightBackground} {\bf{t}} & Uses the 12-hour clock and displays an uppercase 'A' for any hour before noon; displays an uppercase ''P'' for any hour between noon and 11:59 P.M.\{\{nl\}\}For example, {\bf{P}}\{\{nl\}\}\{\{fa-star\}\}Use \%t if this is the only character in your user-defined numeric format. \tn % Row Count 29 (+ 8) % Row 26 \SetRowColor{white} {\bf{tt}} & For locales that use a 12-hour clock, displays an uppercase 'AM' with any hour before noon; displays an uppercase 'PM' with any hour between noon and 11:59 P.M.\{\{nl\}\}For example, {\bf{PM}}\{\{nl\}\}For locales that use a 24-hour clock, displays nothing. \tn % Row Count 37 (+ 8) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{2.9359 cm} x{14.3341 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{User-Defined Date/Time Formats (cont)}} \tn % Row 27 \SetRowColor{LightBackground} {\bf{z}} & Displays the timezone offset without a leading zero\{\{nl\}\}For example, {\bf{+0}}\{\{nl\}\}\{\{fa-star\}\}Use \%z if this is the only character in your user-defined numeric format. \tn % Row Count 6 (+ 6) % Row 28 \SetRowColor{white} {\bf{zz}} & Displays the timezone offset with a leading zero\{\{nl\}\}For example, {\bf{+00}} \tn % Row Count 9 (+ 3) % Row 29 \SetRowColor{LightBackground} {\bf{zzz}} & Displays the full timezone offset\{\{nl\}\}For example, {\bf{+00:00}} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{Uses {\bf{2nd of March 2008 16:07:04 GMT}} as the example Date \& Time} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Source}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{\{\{link="https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.format(v=vs.110).aspx"\}\}Strings.Format Method} \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}