Javascript Date Object Comparison with hidden value -



Javascript Date Object Comparison with hidden value -

i have been reading obsessively in how perform date object comparing in javascript. got ideas , pointers, cant seem joy.

here issue. using jquery datepicker set hidden value. if hidden value changes, compare date today's date, if match, send alert console.

here script. no errors reported in chrome console; doesn't seem want create date comparing after.

var date2 = new date(); $("select[name=sanctiondatestart_hidden]").change(function () { if ($("select[name=sanctiondatestart_hidden]").gettime() == date2.gettime()) alert("yayayayaya"); });

appreciate insight cares share.

edit: here ended resolving issue, posting in case else can utilize this. post below help me going in right direction.

var date2 = new date(); $("#sanctiondatestart").datepicker({ altfield: "#sanctiondatestart_hidden", altformat: "yy-mm-dd", mindate: new date() }).datepicker("setdate", "{$data.sanctiondatestart}").change(function () { $('#sanctiondateend').datepicker('option', 'mindate', $(this).datepicker('getdate')); if ($("#sanctiondatestart").datepicker("getdate").getfullyear() == date2.getfullyear() && $("#sanctiondatestart").datepicker("getdate").getmonth() == date2.getmonth() && $("#sanctiondatestart").datepicker("getdate").getdate() == date2.getdate()) { alert ('todays date'); } });

javascript date time includes current date , hr , minutes , seconds , milliseconds. seldom match date picked date picker

var date2 = new date(); var onlydatewithouttime = new date( date2.getfullyear() , date2.getmonth() , getdate() , 0,0,0,0);

use onlydatewithouttime in comparisons.

or do

var date2 = new date(); var pickeddate = $("select[name=sanctiondatestart_hidden]").gettime(); if ( pickeddate.getfullyear() == date2.getfullyear() && pickeddate.getmonth() == date2.getmonth() && pickeddate.getdate() == date2.getdate() ) { }

javascript object date comparison

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -