zoukankan      html  css  js  c++  java
  • delphi 13位时间戳互转

    //获取13或10位时间戳 时区固定了 好像有问题
    function Gettamptime(vlen: Integer): string;
    var
    timen, time2: TDateTime;
    ss2, ss3: Int64;
    begin
    timen := now;
    time2 := EncodeDateTime(1970, 1, 1, 0, 0, 0, 0);
    ss2 := 28800000;
    ss3 := MilliSecondsBetween(timen, time2);
    ss3 := ss3 - ss2;
    Result := InttoStr(ss3);
    if vlen = 13 then
    Result := Result
    else if vlen = 10 then
    Result := Copy(Result, 1, 10);
    end;
    ///////////////标准正确的//////////////////////
    
    function Gettamptime2(vlen: Integer): string;
    
    var
    ss: string;
    begin
    if vlen = 13 then
    begin
    ss := DateTimeToTimeStamp(now).time .ToString;
    Result := IntToStr(DateTimeToUnix(Now,false)) + Copy(ss,Length(ss) - 2,Length(ss) );
    end
    else if vlen = 10 then
    begin
    Result := IntToStr(DateTimeToUnix(Now,false));
    end
    end;
    
    
    //转位普通时间
    
    function gettamptotime(vtamp: string): string;
    //1582688206607
    var
    ls10,lms: string;
    
    begin
    if Length(vtamp) = 10 then
    
    Result := FormatDateTime('yyyy-MM-dd hh:mm:ss',UnixToDateTime(StrToInt64(vtamp),false))
    else if Length(vtamp) = 13 then
    begin
    ls10 := Copy(vtamp,1,10);
    lms := Copy(vtamp,11,13);
    Result := FormatDateTime('yyyy-MM-dd hh:mm:ss',UnixToDateTime(StrToInt64(ls10),false));
    Result := Result +'.' + lms;
    end;
    end;
  • 相关阅读:
    perl oneline
    perl修改镜像源地址
    pandas 模块
    django学习
    python- shutil 高级文件操作
    小爬虫爬一个贴吧网页的图片
    Python Tkinter的学习
    python的帮助信息的写法
    python3.5+tornado学习
    LinkedList,ArrayList,HashMap,TreeMap
  • 原文地址:https://www.cnblogs.com/iwana/p/12882211.html
Copyright © 2011-2022 走看看