This code places three Elementary Datetime widgets on a window, each of them exemplifying the widget\textquotesingle{}s different usage.

The first of them is {\bfseries \char`\"{}only Date display\char`\"{}}\+:  
\begin{DoxyCodeInclude}
   \textcolor{comment}{//datetime showing only DATE}
   datetime = elm_datetime_add(bx);
   evas\_object\_size\_hint\_weight\_set(datetime, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(datetime, EVAS\_HINT\_FILL, 0.5);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_HOUR, EINA\_FALSE);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_MINUTE, EINA\_FALSE);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_AMPM, EINA\_FALSE);
   elm\_box\_pack\_end(bx, datetime);
   evas\_object\_show(datetime);

\end{DoxyCodeInclude}


For {\bfseries \char`\"{}only Time display\char`\"{}}, see the second datetime\+:  
\begin{DoxyCodeInclude}
   \textcolor{comment}{//datetime showing only TIME}
   datetime = elm_datetime_add(bx);
   evas\_object\_size\_hint\_weight\_set(datetime, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(datetime, EVAS\_HINT\_FILL, 0.5);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_YEAR, EINA\_FALSE);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_MONTH, EINA\_FALSE);
   elm\_datetime\_field\_visible\_set(datetime, ELM\_DATETIME\_DATE, EINA\_FALSE);
   elm\_box\_pack\_end(bx, datetime);
   evas\_object\_show(datetime);

\end{DoxyCodeInclude}


The third one will display datetime shows both {\bfseries Date and Time}, corresponding format will be taken from system {\bfseries locale}. Note, besides, that the strings are different for different language settings.

{\bfseries Datetime format} can be programmatically set by using elm\+\_\+datetime\+\_\+format\+\_\+set()\+:  
\begin{DoxyCodeInclude}
   \textcolor{comment}{//datetime showing both DATE and TIME}
   datetime = elm_datetime_add(bx);
   evas\_object\_size\_hint\_weight\_set(datetime, EVAS\_HINT\_EXPAND, EVAS\_HINT\_EXPAND);
   evas\_object\_size\_hint\_align\_set(datetime, EVAS\_HINT\_FILL, 0.5);
   elm\_box\_pack\_end(bx, datetime);
   evas\_object\_show(datetime);

\end{DoxyCodeInclude}
 The default format of any locale consists\+:
\begin{DoxyItemize}
\item Year Field
\item Month Field
\item Date Field
\item Hour Field(12hr/24hr format)
\item Minute Field
\item A\+M/\+PM (if exists).
\end{DoxyItemize}

This is how the example program\textquotesingle{}s window looks like with the datetime widget showing only date, only time and both date \& time\+:

 
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{screenshots/datetime_example}}
\end{DoxyImageNoCaption}


See the full \hyperlink{datetime_example_c}{source code} for this example. 