我正在尝试为 dateTimePicker 设置特定日期,但不确定如何正确执行。目标是从文本文档中加载用户上次加载插入的日期和时间,每次用户加载应用程序时,然后将新日期保存为字符串以供下次使用加载到 dateTimePicker 中。
这样它就不会设置,我不确定如何加载字符串,例如"25/03/2017":
dateTimePicker.Value = new DateTime(1978, 05, 22);
Run Code Online (Sandbox Code Playgroud)
将其用作字符串以进行进一步处理:
string bd = dateTimePicker.Value.ToString("yyyy-M-d");
Run Code Online (Sandbox Code Playgroud) 我需要一种从格式为 DD-MM-YYYY 的日期获取当天名称的方法,例如星期一、星期二 我正在使用引导程序日期时间选择器,当我选择日期时,该值的格式仅为 DD-MM- YYYY,我无法使用,getDay()因为格式不符合它。
我也无法使用new Date(),因为我必须是从日历中选择的日期。不是今天的日期。当我运行以下代码时,出现错误:
date.getDay()不是一个函数。
$('#datepicker').datetimepicker().on('dp.change', function (event) {
let date = $(this).val();
let day = date.getDay();
console.log(day);
});
```
Anyone any ideas?
Run Code Online (Sandbox Code Playgroud) 目标是创建类似于此问题的屏幕截图的 DateTimePicker 。
第一次尝试覆盖 OnPaint:
public class MyDateTimePicker : DateTimePicker
{
private Image _image;
public MyDateTimePicker() : base()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw |
ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
}
[Browsable(true)]
public override Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor = value;
}
}
[Category("Appearance")]
public Color BorderColor { get; set; } = Color.Black;
[Category("Appearance")]
public Color TextColor { get; set; } = Color.Black;
[Category("Appearance")]
public Image Image
{
get
{
return _image;
}
set
{ …Run Code Online (Sandbox Code Playgroud) 我有一个日期/时间字段,我需要有一个日期/时间选择器,但几乎不可能找到一个,一个体面的(我已经google搜索疯狂).我试过这个选择器http://electronicholas.com/calendar但它在Ruby on Rails中,我不知道如何转换它.有任何想法吗?我主要运行jquery但是如果需要我会使用另一个lib.
我以前查询:
Dim a As String
a = "INSERT INTO tblVisitor(Name, Sex, TimeIn, EnterDate)
VALUES('"& txtName.Text &"', '"& cboSex.Text &"', '"& Now() &"', '"& DateTime.Parse(cboEnterDate.Text) &"')"
myCommand = New SqlCommand(a, myConnection)
myCommand.ExecuteNonQuery()
........................................
Run Code Online (Sandbox Code Playgroud)
哪个cboEnterDate是我的DateTime Picker.然后我收到了消息:
Conversion failed when converting date time from character string.
Run Code Online (Sandbox Code Playgroud)
请帮忙.
我正在使用datetimepicker来获取两个日期.他们是这样出来的:24-11-2011 ..
我希望有他们这样的:2011-11-24..
我试图通过这种方法来实现这一点,但它只改变了界面上的datetimepicker.
DateTimePicker1.Format = DateTimePickerFormat.Custom;
DateTimePicker1.CustomFormat = "yyyy-MM-dd";
Run Code Online (Sandbox Code Playgroud)
这是我的代码.输出说24-11-2011.我想要它说2011-11-24.
string sta = dateTimePicker1.Value.ToShortDateString();
string en = dateTimePicker2.Value.ToShortDateString();
Console.WriteLine(sta);
ctrscan.getListOfDates(sta, en);
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
谢谢
我在我的视图(JS)中有这个代码:
$("#mydivelement").timepicker();
Run Code Online (Sandbox Code Playgroud)
它不是时间选择器,而是显示datetimepicker.如果重要的话,我在布局页面中设置了datepicker默认值:
$.datepicker.setDefaults({
dateFormat: 'dd/mm/yy',
yearRange: '1930:2012',
changeYear: true,
changeMonth: true,
autoSize: true,
showAnim: 'slideDown',
firstDay: 1
});
Run Code Online (Sandbox Code Playgroud)
更新:使用Library-jquery-ui-timepicker-addon.js
Try
DateTimePicker1.Format = DateTimePickerFormat.Custom
' Display the date as "2012-10-24 21:47:09".
DateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm:ss"
strQuery = "INSERT INTO TimeClockInfo(IdTimeClock, First_Name, Last_Name, LogTime, In_Out) VALUES('" & AddTimeEmplyIdBox.Text & "','" & AddTimeEmplyFNBox.Text & "','" & AddTimeEmplyLNBox.Text & "','" & DateTimePicker1.Value & "','in')"
SQLCmd = New MySqlCommand(strQuery, dbCon)
dbCon.Open()
SQLCmd.ExecuteNonQuery()
dbCon.Close()
MsgBox("TimeClock Data Added Successfully!")
Catch ex As Exception
MsgBox("Failure!", ex.Message)
End Try
Run Code Online (Sandbox Code Playgroud)
这将返回value属性中日期和时间的原始格式?我在这做错了什么?
我正在尝试学习如何根据用户选择的时间来安排图片.
这是带有问题的代码:
private void startjob()
{
string theDate = DateTimePicker1.Value.ToString();
DateTime dt = Convert.ToDateTime(date);
{
DateTime start = new DateTime(2009, 12, 9, 10, 0, 0); //How Do I make this to read the string that is converted from DateTimePicker instead of this?
DateTime end = new DateTime(2009, 12, 10, 12, 0, 0); //How Do I make this to read the string that is converted from DateTimePicker instead of this?
DateTime now = DateTime.Now;
if ((now > start) && (now < …Run Code Online (Sandbox Code Playgroud) 我有这个jsp代码(由http://eonasdan.github.io/bootstrap-datetimepicker/拍摄)
<div class='input-group date' id='datetimepicker5'>
<input ng-model="utente.dt_nascita" type='text' class="col-sm-3 form-control" data-date-format="YYYY/MM/DD"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
这个代码在我的controller.js中:
$('#datetimepicker5').datetimepicker({
pickTime: false,
autoclose : true
});
Run Code Online (Sandbox Code Playgroud)
我不想要时间!我希望那个datapicker只询问日期,但事实并非如此.
jsp datetimepicker twitter-bootstrap-3 bootstrap-datetimepicker
datetimepicker ×10
c# ×4
datetime ×2
javascript ×2
jquery ×2
vb.net ×2
winforms ×2
.net ×1
function ×1
jsp ×1
methods ×1
time ×1
timepicker ×1