Tag: date

DateTime.TryParse问题,date为yyyy-dd-MM格式

我以string格式“2011-29-01 12:00 am”有以下date。 现在我试图用下面的代码将它转换为datetime格式: DateTime.TryParse(dateTime, out dt); 但我总是把dt当成{1/1/0001 12:00:00 AM},你能告诉我为什么吗? 以及如何将该string转换为date。 编辑:我刚才看到大家提到使用格式参数。 我现在要提到,我不能使用格式参数,因为我有一些设置来select用户想要的自定义date格式,并基于该用户能够通过jQuery datepicker自动获取该格式的文本date。

用户友好的时间格式在Python?

Python:我需要在“1天前”,“2小时前”格式中显示文件修改时间。 有没有准备好这样做? 它应该是英文的。

可以在文件名或扩展名中使用的DateTime.ToString()格式?

我想添加一个时间戳到文件名作为文件被创build,但我试过的大部分DateTime方法输出的东西与空格和斜线。 例如: Debug.WriteLine(DateTime.Now.ToString()); // <– 9/19/2012 1:41:46 PM Debug.WriteLine(DateTime.Now.ToShortTimeString()); // <– 1:41 PM Debug.WriteLine(DateTime.Now.ToShortDateString()); // <– 9/19/2012 Debug.WriteLine(DateTime.Now.ToFileTime()); // <– 129925501061462806 ToFileTime()作品,但不完全是人类可读的。 我怎样才能把输出格式化为一个可读的时间戳,date和时间可以在文件名或扩展名中使用? 好像2011-19-9–13-45-30 ?

DateTime可以在64位环境中破解吗?

在C#中,只要一个variables的值最多为native int (即在32位运行时环境中为4个字节,在64位中为8个字节), native int其设置为primefaces。 在包含所有引用types和大多数内置值types( byte , short , int , long等)的64位环境中。 设置一个更大的值不是primefaces的,只会更新内存的一部分,会造成撕裂。 DateTime是一个只包含一个包含其所有数据( Ticks和DateTimeKind )的ulong字段的结构, ulong本身在64位环境中是primefaces的。 这是否意味着DateTime也是primefaces的? 或者下面的代码是否会导致在某个点上撕裂? static DateTime _value; static void Main() { for (int i = 0; i < 10; i++) { new Thread(_ => { var random = new Random(); while (true) { _value = new DateTime((long)random.Next() << 30 […]

Joda-Time DateTimeFormatter类的线程安全吗?

Joda-Time DateTimeFormatter类是否线程安全 ? 一旦我从DateTimeFormat.forPattern得到一个实例,它的各种parsing方法可以被多个线程调用吗? DateTimeFormatter的Javadocs没有提到线程的安全性。

在Javascript中确定date平等

我需要找出用户select的两个date在Javascript中是否相同。 date传递给这个函数的string(“xx / xx / xxxx”),这就是我需要的所有粒度。 这是我的代码: var valid = true; var d1 = new Date($('#datein').val()); var d2 = new Date($('#dateout').val()); alert(d1+"\n"+d2); if(d1 > d2) { alert("Your check out date must be after your check in date."); valid = false; } else if(d1 == d2) { alert("You cannot check out on the same day you […]

使用新的date时间API格式化date

我正在玩新的date时间API,但运行时: public class Test { public static void main(String[] args){ String dateFormatted = LocalDate.now() .format(DateTimeFormatter .ofPattern("yyyy-MM-dd HH:mm:ss")); System.out.println(dateFormatted); } } 它抛出: Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay at java.time.LocalDate.get0(LocalDate.java:680) at java.time.LocalDate.getLong(LocalDate.java:659) at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298) at java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2543) at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2182) at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1745) at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1719) at java.time.LocalDate.format(LocalDate.java:1685) at Test.main(Test.java:23) 在查看LocalDate类的源代码时,我看到: private int get0(TemporalField field) { switch ((ChronoField) […]

java中的“漂亮打印”持续时间

有没有人知道一个Java库,可以漂亮的打印一个数字以毫秒为单位,就像c#一样? 例如123456毫秒,会打印为4d1h3m5s (可能不准确,但你希望看到我得到什么!!) -高手

我怎样才能计算打字稿中的两个date之间的时间

这在Javascript中起作用 new Date()-new Date("2013-02-20T12:01:04.753Z") 但在打字稿中,我不能rest两个新的date Date("2013-02-20T12:01:04.753Z") 不要工作,因为paremater不符合date签名

如何排除SQL Server查询中的周末date?

如何排除星期六或星期日的DateTime列中的值? 例如,给出以下数据: date_created '2009-11-26 09:00:00' — Thursday '2009-11-27 09:00:00' — Friday '2009-11-28 09:00:00' — Saturday '2009-11-29 09:00:00' — Sunday '2009-11-30 09:00:00' — Monday 这是我正在寻找的结果: date_created '2009-11-26 09:00:00' — Thursday '2009-11-27 09:00:00' — Friday '2009-11-30 09:00:00' — Monday 谢谢!