如何在Windows窗体中获得hh:mm:ss的秒数 [英] How to get seconds into hh:mm:ss in windows form

查看:54
本文介绍了如何在Windows窗体中获得hh:mm:ss的秒数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个存储过程来将hh:mm:ss转换为秒。现在验证我需要将秒转换为hh:mm:ss并将其显示在以冒号分隔的窗口形式的单个框中。需要使用c#执行此操作,请指导我分离这些值并通过方式在窗体中显示of c#。



我尝试了什么:



i转换秒数进入hh:mm:ss我想知道如何分离它并使用c#

i created a stored procedure to convert the hh:mm:ss into seconds. Now for verifying i need to convert the seconds into hh:mm:ss and show it in individual boxes in windows form seperated by colon.i need to perform this using c# kindly guide me in separating these values and show it in windows form by means of c#.

What I have tried:

i converted the seconds into hh:mm:ss i want to know how to separate it and display in the windows form using c#

推荐答案

在Windows窗体中显示在以下示例中, str 将是00:20:34

In the following example, str will be "00:20:34"
TimeSpan test = TimeSpan.FromSeconds(1234);
string str = test.ToString();


你需要转换第二到DateTime对象

You need to convert second to DateTime object
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
origin.AddSeconds(timestamp);





之后,您可以获得小时,分钟,秒等...来自DateTime对象



After that, you can get hour, min, sec, etc... from DateTime object

var hour = origin.Hour;
var min = origin.Minute;
var sec = origin.Second;





了解更多信息; https://msdn.microsoft.com/tr-tr/library /system.datetime(v=vs.110).aspx [ ^ ]


这篇关于如何在Windows窗体中获得hh:mm:ss的秒数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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