开发者

jQuery datepicker get current date from server-side

开发者 https://www.devze.com 2022-12-22 14:16 出处:网络
How can i get current date from server-side (such as new Date 开发者_如何学Cfrom server date time not from client\'computer date), when i use jQuery datepicker?

How can i get current date from server-side (such as new Date 开发者_如何学Cfrom server date time not from client'computer date), when i use jQuery datepicker?

Do i need get time from server and pass it to the js code? How can i do it. i am using classic asp


If you only care about the date you can simply add the date to a javascript variable when you are creating the page. Something like the following

<script type="text/javascript">
  var date = <%=date()%>;
</script>

Just use that date var to set the date for the datepicker.


This is a little approach.

Step 1: Create an hidden input field anywhere on the page..

<input type="hidden" name="mydate" value=""/>

Step 2: Insert the php date code in the value attribute..

<?php echo date('D, d, Y') ?>

Step 3: now use jquery to get the value of this field and assign it to a variable..

finished


Why can you not just set the date inline as the input value? For example...

<input type="text" name="mydate" value="<%=FormatDateTime(Now,2)%>"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消