Îá°®Æƽâ - 52pojie.cn

 ÕÒ»ØÃÜÂë
 ×¢²á[Register]

QQ怬

Ö»ÐèÒ»²½£¬¿ìËÙ¿ªÊ¼

²é¿´: 1206|»Ø¸´: 5
ÊÕÆð×ó²à

[Òѽâ¾ö] Python Ϊʲô ͬһ¸öʱ¼ä´Á timeºÍdatetimeת»»µÄÈÕÆÚ¸ñʽÏà²î8Сʱ£¿

[¸´ÖÆÁ´½Ó]
zh648990 ·¢±íÓÚ 2022-5-20 09:52
±¾Ìû×îºóÓÉ zh648990 ÓÚ 2022-5-20 10:06 ±à¼­

[Python] ´¿Îı¾²é¿´ ¸´ÖÆ´úÂë
def timeStamp(x):
    time_stamp_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(x) / 1000))
    time_stamp_date = datetime.utcfromtimestamp(int(x) / 1000).strftime('%Y-%m-%d %H:%M:%S')
    print('time Ä£¿é£º{}, datetime Ä£¿é£º{}'.format(time_stamp_time, time_stamp_date))


timeStamp('1653897466000')


´òÓ¡½á¹û

time Ä£¿é£º2022-05-30 15:57:46, datetime Ä£¿é£º2022-05-30 07:57:46

·¢ÌûÇ°ÒªÉÆÓá¾ÂÛ̳ËÑË÷¡¿¹¦ÄÜ£¬ÄÇÀï¿ÉÄÜ»áÓÐÄãÒªÕҵĴ𰸻òÕßÒѾ­ÓÐÈË·¢²¼¹ýÏàͬÄÚÈÝÁË£¬ÇëÎðÖظ´·¢Ìû¡£

Ñô¹â·Ê·Ê ·¢±íÓÚ 2022-5-20 10:00
UTC¾ÍÊÇ0ʱÇøµÄʱ¼ä£¬¶øÄãlocaltimeÊDZ¾µØʱ¼ä£¬ÔÚÖйúÓ¦¸Ã¶¼ÊǶ«°ËÇø£¬²î8¸öСʱÊÇÕý³£µÄ¡£
ynboyinkm ·¢±íÓÚ 2022-5-20 10:01
ÊÇСÁõѽ ·¢±íÓÚ 2022-5-20 10:02
ynboyinkm ·¢±íÓÚ 2022-5-20 10:04
ÎÒÒ»°ã¶¼ÓÃdatetime.now()À´È¡ÏÖÔÚµÄʱ¼ä£¡
 Â¥Ö÷| zh648990 ·¢±íÓÚ 2022-5-20 10:06
ÊÇСÁõѽ ·¢±íÓÚ 2022-5-20 10:02
ÒòΪ utcfromtimestamp °É

¶Ô ¹ûÈ»ÊÇ utcfromtimestamp  Õâ¸öµÄÎÊÌâ ÎÒ»»³É fromtimestamp ¾ÍÒ»ÑùÁË
ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | ×¢²á[Register]

±¾°æ»ý·Ö¹æÔò

·µ»ØÁбí

RSS¶©ÔÄ|СºÚÎÝ|´¦·£¼Ç¼|ÁªÏµÎÒÃÇ|Îá°®Æƽâ - LCG - LSG ( ¾©ICP±¸16042023ºÅ | ¾©¹«Íø°²±¸ 11010502030087ºÅ )

GMT+8, 2025-1-13 07:54

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí