DateTime仅限日期,但仅限于DateTime类型 [英] DateTime to date Only But In DateTime type only

查看:115
本文介绍了DateTime仅限日期,但仅限于DateTime类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个DateTime变量转换为shortDate,然后再次将其保存为DateTime格式.但是,当我这样做时,在类型转换之后,我得到了timeStamp和日期,这是我不想要的.

I want to convert one DateTime variable into shortDate and again save it into DateTime format. But When I do so, after type conversion I get the timeStamp along with the date, which I don''t want.

推荐答案

DateTime数据类型存储将具有时间戳.

您可以在检索时将其转换为所需的格式,或者将数据另存为字符串.
DateTime datatype storage will have timestamp in it.

Either you convert it into desired format at the time of retrieval OR save data as a string.


您好,请参见此处:

假设您在datepicker1中的值(日期时间)为

(
DateTime dt =新的DateTime(datepicker1);
Console.WriteLine(dt.ToString());
Console.WriteLine(dt.ToString("yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat));


注意:此处datepicker1是DatePicker控件


使用c#将日期时间转换为日期 [
hi see here:

suppose u r value(datetime) in datepicker1 then

(
DateTime dt = new DateTime(datepicker1);
Console.WriteLine (dt.ToString());
Console.WriteLine (dt.ToString("yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat));


note:here datepicker1 is a DatePicker Control


Convert Datetime into date using c#[^]


你好,

试试这个,

Hi,

try this,

DateTime etim = Convert.ToDateTime("mm/dd/yyyy");



谢谢,
jeyamothi



Thanks,
jeyamothi


这篇关于DateTime仅限日期,但仅限于DateTime类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆