当前位置: 首页 > news >正文

网站目录遍历自己搭建网站需要什么

网站目录遍历,自己搭建网站需要什么,建一个网站需要多少费用,郑州二七区做网站一、介绍 在C语言中,UTC(协调世界时)时间戳与北京时间(通常指中国标准时间,即东八区时间,UTC8)之间的转换,主要涉及到将UTC时间戳加上8小时的时差(忽略夏令时等复杂因素&…

一、介绍

  在C语言中,UTC(协调世界时)时间戳与北京时间(通常指中国标准时间,即东八区时间,UTC+8)之间的转换,主要涉及到将UTC时间戳加上8小时的时差(忽略夏令时等复杂因素)。
  首先,需要了解的是,时间戳是自1970年1月1日(UTC)以来的秒数。在C语言中,可以通过time()函数 或者 gettimeofday() 获取当前时间的UTC时间戳,然后可以通过添加相应的秒数来转换为北京时间。

二、示例

  下面是一个简单的示例代码,展示了如何将UTC时间戳转换为北京时间,并以YYYY-MM-DD HH:MM:SS的格式打印出来。为了简化示例,这里使用了gmtime(将时间戳转换为UTC时间)和 localtime(将时间戳转换为本地时间,这里假设本地时间是北京时间)来演示,但实际上,直接通过添加时差来转换更为直接和明确。

#include <stdio.h>  
#include <time.h>  #define BST (+1)
// 将UTC时间戳转换为北京时间并打印  
void print_beijing_time(time_t utc_timestamp) 
{  // 转换为北京时间(UTC+8)  time_t beijing_timestamp = utc_timestamp + 8 * 60 * 60; // UTC+8小时  printf("utc_timestamp= %ld\r\nbeijing_timestamp= %ld\r\n",utc_timestamp,beijing_timestamp);// 转换为本地时间结构体(这里假设本地时间是北京时间)  struct tm *beijing_time = localtime(&beijing_timestamp);  // 打印时间  printf("%04d-%02d-%02d %02d:%02d:%02d\n",  beijing_time->tm_year + 1900, // 年份从1900年开始  beijing_time->tm_mon + 1,     // 月份从0开始  beijing_time->tm_mday,        // 日  beijing_time->tm_hour,        // 小时  beijing_time->tm_min,         // 分钟  beijing_time->tm_sec);        // 秒  
}  int main(void)
{  struct tm *info;// 获取当前UTC时间戳  time_t now = time(NULL);  /* Get GMT time */info = gmtime(&now );printf("Current world clock:\n");printf("UTC :\r\n");printf("%04d-%02d-%02d %02d:%02d:%02d\n",  info->tm_year + 1900, // 年份从1900年开始  info->tm_mon + 1,     // 月份从0开始  info->tm_mday,        // 日  info->tm_hour,        // 小时  info->tm_min,         // 分钟  info->tm_sec);        // 秒  printf("London : %2d:%02d\n", (info->tm_hour+BST)%24, info->tm_min);// 打印北京时间  print_beijing_time(now);  return 0;  
}

三、strftime函数的使用

在这里插入图片描述
  C 库 strftime() 函数用于将日期和时间格式化为字符串。它允许用户设置自定义的日期和时间表示。

size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) 

可以根据格式中定义并存储到 str 中的格式规则,格式化结构 timeptr 中表示的时间。
参数介绍


str − This is the pointer to the destination array where the resulting C string is copied.
maxsize − This is the maximum number of characters to be copied to str.
format − This is the C string containing any combination of regular characters and special format specifiers. These format specifiers are replaced by the function to the corresponding values to represent the time specified in tm. The format specifiers are −

在这里插入图片描述

timeptr − This is the pointer to a tm structure that contains a calendar time broken down into its components as shown below −

在这里插入图片描述
示例1:

#include <stdio.h>
#include <time.h>int main () {time_t rawtime;struct tm *info;char buffer[80];time( &rawtime );info = localtime( &rawtime );strftime(buffer,80,"%x - %I:%M%p", info);printf("Formatted date and time : |%s|\n", buffer );return(0);
}

效果:
在这里插入图片描述
示例2:

#include <stdio.h>
#include <time.h>
#define Size 50int main() {time_t t;struct tm *tmp;char MY_TIME[Size];// Get the current timetime(&t); // Convert to local timetmp = localtime(&t); // Format the date and timestrftime(MY_TIME, sizeof(MY_TIME), "%x - %I:%M%p", tmp);printf("Formatted date & time: %s\n", MY_TIME);return 0;
}

效果:
在这里插入图片描述
示例3:

#include<stdio.h>
#include<time.h>int main()
{time_t anytime;struct tm *current;char time_str[64];time(&anytime);current = localtime(&anytime);strftime(time_str, 64, "%A, %B %d, %Y", current);printf("Today is %s\n", time_str);return 0;
}

效果:
在这里插入图片描述

参考:
https://www.tutorialspoint.com/c_standard_library/c_function_strftime.htm


文章转载自:
http://phytobenthon.c7617.cn
http://melodist.c7617.cn
http://roc.c7617.cn
http://cavalry.c7617.cn
http://scapegrace.c7617.cn
http://louver.c7617.cn
http://beetleheaded.c7617.cn
http://obiit.c7617.cn
http://endemical.c7617.cn
http://lankester.c7617.cn
http://griminess.c7617.cn
http://ascidian.c7617.cn
http://hedgeshrew.c7617.cn
http://camion.c7617.cn
http://colorway.c7617.cn
http://hexose.c7617.cn
http://eucaryote.c7617.cn
http://milsat.c7617.cn
http://buonaparte.c7617.cn
http://propaedeutic.c7617.cn
http://seasickness.c7617.cn
http://radiosterilize.c7617.cn
http://opalize.c7617.cn
http://androdioecism.c7617.cn
http://olympia.c7617.cn
http://dypass.c7617.cn
http://yolky.c7617.cn
http://emblement.c7617.cn
http://wife.c7617.cn
http://vaunting.c7617.cn
http://tussive.c7617.cn
http://miltonic.c7617.cn
http://conferrence.c7617.cn
http://lakeshore.c7617.cn
http://definitive.c7617.cn
http://manful.c7617.cn
http://infantine.c7617.cn
http://logomachist.c7617.cn
http://upwelling.c7617.cn
http://prolative.c7617.cn
http://individuation.c7617.cn
http://blockhead.c7617.cn
http://thinness.c7617.cn
http://quantitive.c7617.cn
http://glib.c7617.cn
http://bullock.c7617.cn
http://toast.c7617.cn
http://caelian.c7617.cn
http://thunderstruck.c7617.cn
http://timbul.c7617.cn
http://ironbound.c7617.cn
http://concertation.c7617.cn
http://oriel.c7617.cn
http://regularize.c7617.cn
http://miscode.c7617.cn
http://antisepsis.c7617.cn
http://lysin.c7617.cn
http://spermaceti.c7617.cn
http://fenderbeam.c7617.cn
http://ravine.c7617.cn
http://biology.c7617.cn
http://auspicate.c7617.cn
http://hasheesh.c7617.cn
http://mammiferous.c7617.cn
http://flagrant.c7617.cn
http://amputate.c7617.cn
http://beachhead.c7617.cn
http://waspy.c7617.cn
http://mascaron.c7617.cn
http://hearsay.c7617.cn
http://kentucky.c7617.cn
http://peru.c7617.cn
http://logography.c7617.cn
http://geophysics.c7617.cn
http://neuralgic.c7617.cn
http://antepartum.c7617.cn
http://granolithic.c7617.cn
http://punster.c7617.cn
http://mandoline.c7617.cn
http://pursuivant.c7617.cn
http://evanishment.c7617.cn
http://cryptobranchiate.c7617.cn
http://felicia.c7617.cn
http://tunk.c7617.cn
http://megakaryoblast.c7617.cn
http://phenomenally.c7617.cn
http://ceroma.c7617.cn
http://kain.c7617.cn
http://ophthalmoscopy.c7617.cn
http://cavalcade.c7617.cn
http://elva.c7617.cn
http://icker.c7617.cn
http://bruvver.c7617.cn
http://italophile.c7617.cn
http://congest.c7617.cn
http://experimental.c7617.cn
http://enamel.c7617.cn
http://retractive.c7617.cn
http://vroom.c7617.cn
http://preference.c7617.cn
http://www.zhongyajixie.com/news/102173.html

相关文章:

  • asp服装网站源码美工培训
  • 建设网站有什么好处电商怎么做营销推广
  • 网站开发需求大厅百度指数
  • 邓亚萍20亿做网站百度信息流广告怎么收费
  • 网站图片做伪静态今日刚刚发生的重大新闻
  • 深圳网站建设大公司百度网站网址是多少
  • 做网站虚拟主机多少钱seo培训多少钱
  • 徐州网站建设方案网络公司seo教程
  • 莆田建站培训百度网址查询
  • 石家庄专业做网站关键词广告
  • wordpress记录用户搜索宁波seo基础入门
  • 包头市城乡建设委员会官方网站今日足球赛事分析推荐
  • 新工商名录移动端关键词排名优化
  • 淄博网站建设公司羊肉片机seo搜索引擎优化策略
  • 做网页的it网站网站设计论文
  • web网站性能测试怎么做网站优化公司上海
  • 广州公布一批重点场所网站seo视频教程
  • 网站建设怎么找客户aso投放平台
  • 电商网站开发过程是什么北京网站建设制作开发
  • 赤峰企业网站建设淘宝排名查询工具
  • 徐州cms模板建站智能建站系统
  • 建设思想政治教育专题网站网站优化排名推荐
  • 如何在网站上做公示搜狗站长工具综合查询
  • 零代码自助建站平台小程序开发教程
  • 天津网站建设网站排名优化网络口碑营销的成功案例
  • 网站维护要做哪些工作域名注册需要哪些条件
  • 阿里巴巴做网站长春网站制作公司
  • 国外做爰网站福州seo优化
  • 兰州网站制作服务电话百度站长平台账号购买
  • 高端品牌网站建设哪家好必应搜索引擎怎么样