jquery Date Time Converting - fabulouscode

Sunday, December 6, 2020

jquery Date Time Converting

 


When Select First Date on Calendar Then Second Date Auto Selected


function loadDatePicker() {
        $("#txtStartDate").datepicker({

            dateFormat: 'dd-M-yy', constrainInput: true,
            onSelect: function (dates) {
                $('#txtEndDate').val("");

                var date = new Date(dates), y = date.getFullYear(), m = date.getMonth();
                
                var lastDay = new Date(y, m + 1, 0);
          
            $('#txtEndDate').val($.datepicker.formatDate('dd-Myy', lastDay));

            
            }
        });

        $('#txtStartDate').val($.datepicker.formatDate("dd-M-yy", new Date()));
        $("#txtEndDate").datepicker({ dateFormat: 'dd-M-yy', constrainInput: true });
        //$('#txtEndDate').val($.datepicker.formatDate("dd-M-yy", new Date()));
        $('#txtEndDate').val("");
     
        $('#txtEndDate').val("");

         
    };

=============================xxx===============================

Help Url ::
https://stackoverflow.com/questions/2402386/jquery-function-to-convert-datetime-split-date-time-2010-10-18-1006-to-retur
https://stackoverflow.com/questions/27193823/date-formatting-in-jquery-dd-mm-yy-to-dd-m-y

Covert Short Date::

var months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
var datetime = (new Date()).toISOString().split('T')[0];
var userDate = datetime;
var date = new Date(userDate),
currentDate = (date.getDate() > 9 ? date.getDate() : "0" + date.getDate()) + '-' + months[date.getMonth()] + '-' + (date.getFullYear() + "").substr(2);

<input type="text" id="tbDateTime" value="2010-10-18 10:06" />
<input type="text" id="tbDate" value="" />
<input type="text" id="tbTime" value="" />

<input type="button" id="btnSubmit" value="Submit" />


<script type="text/javascript">
    $(function () {
        $('#btnSubmit').click(function () {
            var dateTimeSplit = $('#tbDateTime').val().split(' ');

            var dateSplit = dateTimeSplit[0].split('-');
            var currentDate = dateSplit[2] + '/' + dateSplit[1] + '/' + dateSplit[0];
            //currentDate is 18/10/2010

            $('#tbDate').val(currentDate);

            var currentTime = dateTimeSplit[1];
            //currentTime is 10:06

            $('#tbTime').val(currentTime);
        });
    });
</script>
------------------

var d1 = Date.parse('2010-10-18, 10:06 AM');
alert(d1.toString('dd/mm/yyyy HH:mm:ss GMT'));
----------------------------------
var datetime= '2010-10-18 10:06 AM' // Default datetime will be like this.

//By Spliting the input control value with space
var date=datetime.split(' ')[0];
//date -2010-10-18

2 comments:

  1. How to find the perfect slot machine - drmcd
    Search by player, 울산광역 출장마사지 pay lines, 화성 출장안마 jackpot, and video 출장샵 games. If you're searching for a perfect slot 경주 출장샵 machine, search from 양주 출장샵 the best slots

    ReplyDelete
  2. Find code snippets in any language CodeProZone
    https://codeprozone.com/code/cpp/36047/error-ISO-C-forbids-comparison-between-pointer-and-integer-fpermissive-ifsi-b.html
    Its a developer’s community where programmers and developers from the globe share the codes and many can learn from their experiences. Here codes are shared written by Master Coders and many follow their pattern. These codes help developers to grow and be at home in their skills. By using these codes, a developer can develop their projects faster, can easily understand and may have more chances to boom in their field.

    ReplyDelete

I am Safiqul Islam Tuhin