gpt4 book ai didi

datetime - D:将日期时间转换为日期:无法从日期时间转换为日期

转载 作者:行者123 更新时间:2023-12-01 16:14:49 25 4
gpt4 key购买 nike

我需要将 DateTime 类型转换为 Date。这是我的代码:

DateTime dt = DateTime(2015, 1, 1, 14, 10, 13);
Date z = cast(Date)dt;

错误:无法从 DateTime 转换为 Date

怎么了?

最佳答案

DateTime 不是日期,您无法转换它。要进行转换,只需访问 DateTime.date() 属性即可:

http://dlang.org/phobos/std_datetime.html#.DateTime.date

const pure nothrow @property @safe Date date();

The date portion of DateTime.

关于datetime - D:将日期时间转换为日期:无法从日期时间转换为日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28642647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com