开发者

DateTime calender in asp.net

开发者 https://www.devze.com 2023-04-11 18:02 出处:网络
The date time displays as 07/10/2011 01:29:20 I want to display only 07/10/2011 01:29 how can I do that.

The date time displays as 07/10/2011 01:29:20 I want to display only 07/10/2011 01:29 how can I do that.

     DateTime now = DateTime.Now.AddHours(12);
        txt_ExpiresBy.Text = Convert.ToString(now);

And开发者_StackOverflow社区 I have this datetime calendar which I assign it to a text box, I have to assign this calendar to 3 text box, How can I do it. Should I use three Javascript with different name or can I do with this below?

<script type="text/javascript">

        $(function () {
            $('.datePicker').datetimepicker();
        });
    </script>

<asp:TextBox ID="forDatePicker" runat="server" />


txt_ExpiresBy.Text = expirestime.ToString(@"dd/MM/yyyy hh:mm");

The Datetime.ToString() method is pretty flexible or you can use one of the other methods such as ToShortDateString().

See the MSDN docs for more details: http://msdn.microsoft.com/en-us/library/system.datetime.aspx


Using the class name to assign the datetimepicker to multiple textboxes should work just fine.


Use DateTime.ToString() method.

DateTime expirestime = expirestime.AddHours(12);
txt_ExpiresBy.Text = expirestime.ToString();


with overload ToString Method

this.txt_ExpiresBy.Text = DateTime.Now.ToString("dd/mm/yyyy" + " " + "hh:mm");

Regards

0

精彩评论

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

关注公众号