zoukankan      html  css  js  c++  java
  • 基础

     1 #include "stdafx.h"
     2 #include <Windows.h>
     3 #include <iostream>
     4 #include <time.h>
     5 #include <atltime.h>
     6 using namespace std;
     7 
     8 void Method_1();
     9 void Method_2();
    10 void Method_3();
    11 void Method_4();
    12 void Method_5();
    13 void Method_6();
    14 
    15 int main()
    16 {
    17     Method_1();
    18     Method_2();
    19     Method_3();
    20     Method_4();
    21     Method_5();
    22     Method_6();
    23     
    24     
    25     getchar();
    26 
    27     return 0;
    28 }
    29 
    30 void Method_1()
    31 {
    32     time_t t = time(0);
    33     char tmp[64];
    34     strftime(tmp, sizeof(tmp), "%Y/%m/%d %X %A 本年第%j天 %z", localtime(&t));
    35     puts(tmp);
    36 
    37     /*++
    38     size_t strftime(char *strDest, size_t maxsize, const char *format, const struct tm *timeptr);
    39     根据格式字符串生成字符串。
    40     struct tm *localtime(const time_t *timer);
    41     取得当地时间,localtime获取的结果由结构tm返回
    42     返回的字符串可以依下列的格式而定:
    43     %a 星期几的缩写。Eg:Tue
    44       %A 星期几的全名。 Eg: Tuesday
    45         %b 月份名称的缩写。
    46         %B 月份名称的全名。
    47         %c 本地端日期时间较佳表示字符串。
    48         %d 用数字表示本月的第几天 (范围为 00 至 31)。日期
    49         %H 用 24 小时制数字表示小时数 (范围为 00 至 23)。
    50         %I 用 12 小时制数字表示小时数 (范围为 01 至 12)。
    51         %j 以数字表示当年度的第几天 (范围为 001 至 366)。
    52         %m 月份的数字 (范围由 1 至 12)。
    53         %M 分钟。
    54         %p 以 ''AM'' 或 ''PM'' 表示本地端时间。
    55         %S 秒数。
    56         %U 数字表示为本年度的第几周,第一个星期由第一个周日开始。
    57         %W 数字表示为本年度的第几周,第一个星期由第一个周一开始。
    58         %w 用数字表示本周的第几天 ( 0 为周日)。
    59         %x 不含时间的日期表示法。
    60         %X 不含日期的时间表示法。 Eg: 15:26:30
    61         %y 二位数字表示年份 (范围由 00 至 99)。
    62         %Y 完整的年份数字表示,即四位数。 Eg:2008
    63         %Z(%z) 时区或名称缩写。Eg:中国标准时间
    64         %% % 字符。
    65         --*/
    66 }
    67 void Method_2()//windowsAPI 精确到毫秒
    68 {
    69     SYSTEMTIME sys;
    70     GetLocalTime(&sys);
    71     printf("%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d
    ", sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, sys.wDayOfWeek);
    72 
    73 }
    74 
    75 void Method_3()//利用系统函数,还能修改系统时间!!!!谨慎!!!会修改系统时间
    76 {
    77     //system("time");
    78 }
    79 void Method_4() //这种方法是调用当地时间(星期、月份、日期、时间、年份),并且一直更新
    80 {
    81     time_t nowTime;
    82     time(&nowTime);
    83     printf("At now time is %s
    ", ctime(&nowTime));
    84 }
    85 void Method_5()
    86 {
    87     time_t timer;
    88     time(&timer);
    89     tm* t_tm = localtime(&timer);
    90     printf("At now time is %d/%d/%d
    ", t_tm->tm_year + 1900, t_tm->tm_mon + 1, t_tm->tm_mday);
    91     printf("today is %M %d/%d/%d %d:%d
    ", t_tm->tm_year + 1900, t_tm->tm_mon + 1, t_tm->tm_mday, t_tm->tm_hour, t_tm->tm_min, t_tm->tm_sec);
    92 }
    93 void Method_6()
    94 {
    95     CString    strFileName = CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.bmp");
    96 
    97 
    98 }
  • 相关阅读:
    Java如何编写自动售票机程序
    install windows service
    redis SERVER INSTALL WINDOWS SERVICE
    上传文件
    This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
    解决Uploadify上传控件加载导致的GET 404 Not Found问题
    OracleServiceORCL服务不见了怎么办
    Access to the temp directory is denied. Identity 'NT AUTHORITYNETWORK SERVICE' under which XmlSerializer is running does not have sufficient permiss
    MSSQL Server 2008 数据库安装失败
    数据库数据导出成XML文件
  • 原文地址:https://www.cnblogs.com/1228073191Blog/p/7483319.html
Copyright © 2011-2022 走看看