Date in other months

5 Jan 20181 minute to read

DateTimePicker calendar can display the dates in other months at the start or end of the current month. To enable or disable the display of other month dates in the current month, you can use the property called show-other-months. By setting this property value as “true” you can display the dates in other months at the start or end of the current month. By default the value of this property is “true”.

Consider you are going to calculate the monthly report of your company’s employee attendance. To avoid the mistake of selecting other month dates while calculating current month report, you can disable showing other month dates in the current month. You can achieve this requirement by setting show-other-months value as “false”.

  1. Add the following code in your CSHTML page to render DateTimePicker widget.
  • CSHTML
  • /*ej-Tag Helper code to render DateTimePicker*/
    	 
    	@*Add the following code example to the corresponding CSHTML page to render DateTimePicker widget with customized other months*@
    
         <ej-date-time-picker id="DateTime" show-other-months="false"></ej-date-time-picker>
  • CSHTML
  • /*Razor code to render DateTimePicker*/
    
    	 @{Html.EJ().DateTimePicker("DateTime").ShowOtherMonths(false).Render();}

    NOTE

    To render the DateTimePicker Control you can use either Razor or Tag helper code as given in the above code snippet.

    1. The following screenshot displays the output for the above code.

      Showcase for DateTimePicker without other month dates