Tag: datetime

DateTime.Now.ToString(“yyyy-MM-dd hh:mm:ss”)正在返回AM时间而不是PM时间?

我试图通过DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")获取当前时间 但是,这是吐出了我们想要的12个小时的时间。 例如: 它吐出来的东西: 11/14/2011 2:24:56 am 我们想要什么: 11/14/2011 2:24:56 pm 我们做什么noob错误? 任何帮助是极大的赞赏 :)

以毫秒为单位将date时间格式化为string

我想从毫秒的date有一个datetimestring。 这个代码对我来说是典型的,我渴望学习如何缩短它。 from datetime import datetime timeformatted= str(datetime.utcnow()) semiformatted= timeformatted.replace("-","") almostformatted= semiformatted.replace(":","") formatted=almostformatted.replace(".","") withspacegoaway=formatted.replace(" ","") formattedstripped=withspacegoaway.strip() print formattedstripped

如何列出所有的月份名称,例如组合?

目前,我正在为每个月创buildDateTime并将其格式化为仅包含月份。 有没有其他的或更好的方法来做到这一点?

如何将unix时间戳转换为日历datemoment.js

我有一个unix时间戳,我试图将其转换为日历date,如MM / DD / YYYY。 到目前为止,我有这样的: $(document).ready(function() { var value = $("#unixtime").val(); //this retrieves the unix timestamp var dateString = moment(value).calendar(); alert(dateString); }); 当我尝试打印日历date时,窗口显示“date无效”。 谁能帮我吗?

DateTime.Compare如何检查date是否小于30天?

我试图解决帐户是否在30天内到期。 我使用DateTime比较正确吗? if (DateTime.Compare(expiryDate, now) < 30) { matchFound = true; }

如何获得星期几的整数值

如何以整数格式获得一周的哪一天? 我知道ToString将只返回一个string。 DateTime ClockInfoFromSystem = DateTime.Now; int day1; string day2; day1= ClockInfoFromSystem.DayOfWeek.ToString(); /// it is not working day2= ClockInfoFromSystem.DayOfWeek.ToString(); /// it gives me string

为什么我不能检查'DateTime'是否为'Nothing'?

在VB.NET中,有没有办法将DateTimevariables设置为“not set”? 为什么可以将DateTime设置为Nothing ,但不可能检查它是否为Nothing ? 例如: Dim d As DateTime = Nothing Dim boolNotSet As Boolean = d Is Nothing 第二个语句抛出这个错误: 'Is' operator does not accept operands of type 'Date'. Operands must be reference or nullable types.

使用带有UTCdate的AngularJSdatefilter

我有一个以毫秒为单位的UTCdate,我将它传递给Angular的datefilter来进行人类格式化。 {{someDate | date:'d MMMM yyyy'}} 真棒,除了someDate是UTC,datefilter认为它是在当地时间。 如何告诉Angular someDate是UTC? 谢谢。

如何在C#中只设置DateTimevariables的时间部分

我有一个DateTimevariables: DateTime date = DateTime.Now; 我想更改DateTimevariables的时间部分。 但是当我试图访问时间部分(hh:mm:ss)时,这些字段是只读的。 我不能设置这些属性?

你怎么find这个月的最后一天?

可能重复: 如何获得一个月的最后一天? 到目前为止,我有这样的: DateTime createDate = new DateTime(year, month, 1).AddMonths(1).AddDays(-1); 有没有更好的办法?