$(function() {
$('#datepicker').datepicker({
dateFormat: 'yy-dd-mm',
onSelect: function(datetext){
var d = new Date(); // for now
var h = d.getHours();
h = (h < 10) ? ("0" + h) : h ;
var m = d.getMinutes();
m = (m < 10) ? ("0" + m) : m ;
var s = d.getSeconds();
s = (s < 10) ? ("0" + s) : s ;
datetext = datetext + " " + h + ":" + m + ":" + s;
$('#datepicker').val(datetext);
}
});
});
I have used this jquery.. But on converting this to string in ASP, ASP is returning me in another format (say 1/9/2016 ... But the format what asp should return me as string is 01/09/2016). Can someone help me with this ?
答案 0 :(得分:2)
你可以使用
String.Format("{0:yy-dd-mm}", yourParseTime);
答案 1 :(得分:0)
您可以在C#中使用String.Format()
。只需在String.Format()
中传递文本框日期。
试用此代码:
using System;
public class Program
{
public static void Main()
{
DateTime time = DateTime.Now;
Console.WriteLine(String.Format("{0:yy-dd-mm}", time));
}
}
演示: Click here