<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DateTimePicker Archives - The Code Developer</title>
	<atom:link href="https://www.thecodedeveloper.com/category/datetimepicker/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.thecodedeveloper.com/category/datetimepicker/</link>
	<description>The Code Developer is a Programming Blog.</description>
	<lastBuildDate>Wed, 30 Jan 2019 21:22:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Disable Past date time in DateTimePicker jQuery plugin</title>
		<link>https://www.thecodedeveloper.com/disable-past-date-time/</link>
					<comments>https://www.thecodedeveloper.com/disable-past-date-time/#comments</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Sun, 08 Apr 2018 18:53:48 +0000</pubDate>
				<category><![CDATA[DateTimePicker]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=2703</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="disable past date time" decoding="async" fetchpriority="high" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-768x379.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></div>
<p>Nowadays i was working a project and in this project one of the task i am using DateTimePicker jQuery plugin to select date time. According the task requirement I don&#8217;t want to allow user to select any past date time, only user can select current or future date time. So Today in this article i [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/disable-past-date-time/">Disable Past date time in DateTimePicker jQuery plugin</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="disable past date time" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/04/disable-past-date-time-768x379.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></div><p>Nowadays i was working a project and in this project one of the task i am using <a href="https://github.com/xdan/datetimepicker" target="_blank" rel="noopener">DateTimePicker</a> jQuery plugin to select date time. According the task requirement I don&#8217;t want to allow user to select any past date time, only user can select current or future date time. So Today in this article i will explain how to Disable Past date time with DateTimePicker jQuery plugin.</p>
<p><strong>Read Also: </strong> <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">How to Install DateTimePicker jQuery plugin</a></p>
<h2>Disable Past date time in DateTimePicker jQuery plugin</h2>
<p>First we try to disable Past Date with <strong>minDate: 0</strong> option:</p>
<pre class="brush: php; title: ; notranslate">
//minDate option Example
$('#datetimepicker5').datetimepicker({
	minDate:0, // disable past date
});
</pre>
<p><strong>Output: </strong></p>
<p><input id="datetimepicker5" type="text" /></p>
<p>Now i try to disable Past Date and Time with <strong>minDate: 0</strong> and <strong>minTime: 0</strong> option:</p>
<pre class="brush: php; title: ; notranslate">
//minDate and minTime option Example
$('#datetimepicker6').datetimepicker({
	minDate: 0,  // disable past date
	minTime: 0, // disable past time
});
</pre>
<p><strong>Output: </strong></p>
<p><input id="datetimepicker6" type="text" /></p>
<p><strong>In the above output i have found two issue:</strong></p>
<p><strong>Issue 1:</strong> If current time is 2:00 AM, then user can&#8217;t select current time to 2:00 AM.</p>
<p><strong>Issue 2:</strong> If user select future date then some time disable, e.g if current time is 3:00 AM, user can&#8217;t select time to 3:00 AM, 2:00 AM, 1:00 AM. But i want if user select future date then every time should be visible to select.</p>
<p>so here <strong>minTime: 0</strong> option did&#8217;t work for me.</p>
<p>I wrote below code to fix above issues, in this code if user select today date then pass current time with <strong>minTime</strong> option and for future date all time will be visible to select.</p>
<pre class="brush: jscript; title: ; notranslate">
var checkPastTime = function(inputDateTime) {
    if (typeof(inputDateTime) != &quot;undefined&quot; &amp;&amp; inputDateTime !== null) {
        var current = new Date();

        //check past year and month
        if (inputDateTime.getFullYear() &lt; current.getFullYear()) {
            $('#datetimepicker7').datetimepicker('reset');
            alert(&quot;Sorry! Past date time not allow.&quot;);
        } else if ((inputDateTime.getFullYear() == current.getFullYear()) &amp;&amp; (inputDateTime.getMonth() &lt; current.getMonth())) {
            $('#datetimepicker7').datetimepicker('reset');
            alert(&quot;Sorry! Past date time not allow.&quot;);
        }

        // 'this' is jquery object datetimepicker
        // check input date equal to todate date
        if (inputDateTime.getDate() == current.getDate()) {
            if (inputDateTime.getHours() &lt; current.getHours()) {
                $('#datetimepicker7').datetimepicker('reset');
            }
            this.setOptions({
                minTime: current.getHours() + ':00' //here pass current time hour
            });
        } else {
            this.setOptions({
                minTime: false
            });
        }
    }
};

var currentYear = new Date();
$('#datetimepicker7').datetimepicker({
	format:'Y-m-d H:i',
	minDate : 0,
	yearStart : currentYear.getFullYear(), // Start value for current Year selector
	onChangeDateTime:checkPastTime,
	onShow:checkPastTime
});

</pre>
<p><input id="datetimepicker7" type="text" /></p>
<p>I can’t express how happy I am to see my code is working fine.</p>
<p>The post <a href="https://www.thecodedeveloper.com/disable-past-date-time/">Disable Past date time in DateTimePicker jQuery plugin</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/disable-past-date-time/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
		<item>
		<title>Add a DateTimePicker jQuery plugin to Input Field</title>
		<link>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/</link>
					<comments>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/#comments</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Wed, 04 Apr 2018 05:53:56 +0000</pubDate>
				<category><![CDATA[DateTimePicker]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">https://www.thecodedeveloper.com/?p=2713</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="DateTimePicker jQuery plugin" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-768x379.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></div>
<p>This Article shows the simplest way to add date time picker functionality to your websites to provide better end user experience. Here we are using DateTimePicker jQuery plugin to add date-time picker to input field, this article will help you lot for that. This plugin is very simple and easy to implement and provides various [&#8230;]</p>
<p>The post <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">Add a DateTimePicker jQuery plugin to Input Field</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="910" height="449" src="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="DateTimePicker jQuery plugin" decoding="async" loading="lazy" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin.png 910w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-442x218.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2018/03/DateTimePicker-jQuery-plugin-768x379.png 768w" sizes="auto, (max-width: 910px) 100vw, 910px" /></div><p>This Article shows the simplest way to add date time picker functionality to your websites to provide better end user experience. Here we are using <a href="https://github.com/xdan/datetimepicker" target="_blank" rel="noopener">DateTimePicker</a> jQuery plugin to add date-time picker to input field, this article will help you lot for that. This plugin is very simple and easy to implement and provides various options to customize your Date Time Picker as per your project requirement.</p>
<h2><a href="https://www.thecodedeveloper.com/demo/add-datetimepicker-jquery-plugin/" rel="noopener" target="_blank">Live Demo</a></h2>
<h2>Setting up DateTimePicker jQuery plugin</h2>
<p>First include the jQuery library file before the closing <code class="highlighter-code">&lt;/head&gt;</code> tag.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- this file should add inside the &lt;head&gt;&lt;/head&gt; tag --&gt;
&lt;script src=&quot;js/jquery.min.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Now include the js and css files of DateTime Picker jQuery plugin. those files should be add after the <code class="highlighter-code">&lt;/body&gt;</code> tag.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!-- those files should be add after the &lt;/body&gt; tag --&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/jquery.datetimepicker.min.css&quot;/&gt;
&lt;script src=&quot;js/jquery.datetimepicker.js&quot;&gt;&lt;/script&gt;
</pre>
<h4>HTML Code</h4>
<pre class="brush: php; title: ; notranslate">
&lt;input id=&quot;datetimepicker&quot; type=&quot;text&quot; &gt;
</pre>
<h4>JavaScript Code with DatePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function() {
        $('#datetimepicker').datetimepicker();
    });
&lt;/script&gt;
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker"/></p>
<h4>TimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//TimePicke Example
$('#datetimepicker1').datetimepicker();
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker1"/></p>
<h4>Inline DateTimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//Inline DateTimePicker Example
$('#datetimepicker2').datetimepicker({
    format:'Y-m-d H:i',
    inline:true
});
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker2"/></p>
<h4>minDate and maxDate Example</h4>
<pre class="brush: php; title: ; notranslate">
//minDate and maxDate Example
$('#datetimepicker3').datetimepicker({
     format:'Y-m-d',
     timepicker:false,
     minDate:'-1970/01/02', //yesterday is minimum date
     maxDate:'+1970/01/02' //tomorrow is maximum date
});
</pre>
<p><strong>Output:</strong></p>
<p><input type="text" id="datetimepicker3"/></p>
<h4>allow particular Times options with TimePicker Example</h4>
<pre class="brush: php; title: ; notranslate">
//allow particular Times options with TimePicker Example
$('#datetimepicker4').datetimepicker({
	datepicker:false,
	allowTimes:&#x5B;
	  '11:00', '13:00', '15:00', 
	  '16:00', '18:00', '19:00', '20:00'
	]
});
</pre>
<p><input type="text" id="datetimepicker4"/></p>
<h2><a href="https://www.thecodedeveloper.com/download/add-datetimepicker-jquery-plugin.zip" rel="noopener" >Download Code File</a></h2>
<p>The post <a href="https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/">Add a DateTimePicker jQuery plugin to Input Field</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/add-datetimepicker-jquery-plugin/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
	</channel>
</rss>
