DATETIME,如YYYYMMDDHHMMSS [英] DATETIME like YYYYMMDDHHMMSS

查看:84
本文介绍了DATETIME,如YYYYMMDDHHMMSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何获得当地日期时间为YYYYMMDDHHMMSS 14位数字符串???


我很新C ++,但是如果MSDN教程可能就是这样吗

最好与GCC一起使用...... :)


Ferhat

Hi,

How do you get the local date time as YYYYMMDDHHMMSS 14 digit string???

I am very new to C++, but if the MSDN tutorials are like that may be it
is better to go with GCC... :)

Ferhat

推荐答案



" Jazzhouse" < FE **** @ ventusvigor.com>在消息中写道

news:cj *********** @ gnd.k-net.dk ...

"Jazzhouse" <fe****@ventusvigor.com> wrote in message
news:cj***********@gnd.k-net.dk...


如何将本地日期时间设为YYYYMMDDHHMMSS 14位数字符串???

我是C ++的新手,但如果MSDN教程可能是这样的话,那么它就是
更好的GCC ......:)
Hi,

How do you get the local date time as YYYYMMDDHHMMSS 14 digit string???

I am very new to C++, but if the MSDN tutorials are like that may be it is
better to go with GCC... :)




您可以在C,C ++,VC ++,gcc,g ++中以相同的方式实现它,实际上在任何C中或者

世界上的C ++编译器。


#include< time.h>

#include< stdio.h> ;


time_t t =时间(0);

struct tm * lt = localtime(& t);

char time_str [15];

sprintf(time_str,"%04d%02d%02d%02d%02d%02d",

lt-> tm_year + 1900,lt - > tm_mon + 1,lt-> tm_mday,

lt-> tm_hour,lt-> tm_min,lt-> tm_sec);


未经测试的代码


john



You can do it the same way in C, C++, VC++, gcc, g++, in fact in any C or
C++ compiler in the world.

#include <time.h>
#include <stdio.h>

time_t t = time(0);
struct tm* lt = localtime(&t);
char time_str[15];
sprintf(time_str, "%04d%02d%02d%02d%02d%02d",
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min, lt->tm_sec);

Untested code

john


John Harrison写道:
John Harrison wrote:
" Jazzhouse" < FE **** @ ventusvigor.com>在消息中写道
新闻:cj *********** @ gnd.k-net.dk ...
"Jazzhouse" <fe****@ventusvigor.com> wrote in message
news:cj***********@gnd.k-net.dk...


你如何得到YYYYMMDDHHMMSS 14位字符串的本地日期时间???

我是C ++的新手,但如果MSDN教程可能就是这样的话
最好去与GCC ... :))
Hi,

How do you get the local date time as YYYYMMDDHHMMSS 14 digit string???

I am very new to C++, but if the MSDN tutorials are like that may be it
is better to go with GCC... :)



您可以在C,C ++,VC ++,gcc,g ++中以相同的方式实现,实际上在任何C或
C ++编译器中都可以世界。

#include< time.h>
#include< stdio.h>

time_t t = time(0);
struct tm * lt = localtime(& t);
char time_str [15];
sprintf(time_str,"%04d%02d%02d%02d%02d%02d", lt-> tm_year + 1900,lt-> tm_mon + 1,lt-> tm_mday,
lt-> tm_hour,lt-> tm_min,lt-> tm_sec);

未经测试的代码



You can do it the same way in C, C++, VC++, gcc, g++, in fact in any C or
C++ compiler in the world.

#include <time.h>
#include <stdio.h>

time_t t = time(0);
struct tm* lt = localtime(&t);
char time_str[15];
sprintf(time_str, "%04d%02d%02d%02d%02d%02d",
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
lt->tm_hour, lt->tm_min, lt->tm_sec);

Untested code



以上哪部分是C ++?


-

WW aka Attila

:::

在创建此消息时没有树被杀死。然而,许多电子产生了可怕的不便。


Which part of the above is C++?

--
WW aka Attila
:::
No trees were killed in the creation of this message. However, many
electrons were terrible inconvenienced.


白狼在新闻中写道:cj ********** @ phys -news1.kolumbus.fi在

comp.lang.c ++:
White Wolf wrote in news:cj**********@phys-news1.kolumbus.fi in
comp.lang.c++:
上面的哪一部分是C ++?
Which part of the above is C++?




#include< time.h>

#include< stdio.h>


int main()

{

time_t t = time(0);

struct tm * lt = localtime(& t);

char time_str [15];

sprintf(time_str,"%04d%02d%02d%02d%02d%02d",

lt-> tm_year + 1900, lt-> tm_mon + 1,lt-> tm_mday,

lt-> tm_hour,lt-> tm_min,lt-> tm_sec

);

printf("%s\ n",time_str);

}


所有这些显然都是。


Rob。

-
http://www.victim-prime.dsl.pipex.com/

这篇关于DATETIME,如YYYYMMDDHHMMSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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