首页 > 其他分享 >Delphi XE 时间和时间戳互转换

Delphi XE 时间和时间戳互转换

时间:2023-09-22 18:12:24浏览次数:38  
标签:begin end string ss Delphi XE 时间 Result vtamp

uses
  System.DateUtils;

function TForm1.Gettamptime(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 TForm1.GettampToTime(vtamp: string): string;
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;
复制代码

 

标签:begin,end,string,ss,Delphi,XE,时间,Result,vtamp
From: https://www.cnblogs.com/linjincheng/p/17723079.html

相关文章

  • JS实现电子签名,并且将带logo和时间水印的电子签名保存到本地
    页面效果如下 本地保存的电子签名图片如下 具体实现代码如下<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>电子签名</title><style>#canvas{border:1pxsolid#000;margin-bo......
  • css继承,position:fixed固定定位
    CSS继承是指元素可以继承其父元素的某些样式属性值。当一个元素应用了某个样式属性值,而其子元素没有显式地指定该属性值时,子元素会从父元素继承该属性值。以下是一些常见的CSS属性可以被继承的例子:1.字体样式属性:font-family、font-size、font-weight、font-style、line-heig......
  • SyntaxError: invalid property id (浏览器不支持对象...展开)
    SyntaxError:invalidpropertyid(浏览器不支持对象...展开)火狐55以后支持......
  • Redis怎么设置过期时间
    pexpire(Stringkey,longmilliseconds):设置n毫秒后过期。expireAt(Stringkey,longunixTime):设置某个时间戳后过期(精确到秒)。pexpireAt(Stringkey,longmillisecondsTimestamp):设置某个时间戳后过期(精确到毫秒)。persist(Stringkey):移除过期时间。setkvexseconds......
  • nods中mysql时间相差8小时
    前言最近在做自己的一个记账项目,后端nestjs中使用typeorm的mysql。当添加记录时,发现所以时间都相差了8小时。后面查了一下资料发现因为默认timezone是用UTC的。所以只需要设置成我们自己的时区即可。解决方法ormconfig.json{"type":"mysql","host":"localhost","po......
  • GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案
    GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案GPS北斗卫星同步时钟(NTP时间同步)助力化工厂各系统协同方案京准电子科技官微——ahjzsz本项目需配备多台HR-901GB网络时间服务器,各作业部部署一台或多台一级NTP网络时间服务器(炼铁事业部包括高炉、烧结和球团,需配置3台网......
  • 已解决 File “F:\File_Anaconda\2020CV\yolov5-master\20200701.py“, line 5 Sy
    已解决File“F:\File_Anaconda\2020CV\yolov5-master\20200701.py”,line5SyntaxError:Non-UTF-8codestartingwith‘\xc0’infileF:\File_Anaconda\2020CV\yolov5-master\20200701.pyonline5,butnoencodingdeclared;seehttp://python.org/dev/peps/pe......
  • JAVA 后端 记录方法运行时间
     LocalDateTimeldStart=LocalDateTime.now();//记录开始时间//中间是需要计算时间的代码段落LocalDateTimeldEnd=LocalDateTime.now();//记录结束时间Durationdu=Duration.between(ldStart,ldEnd);LongcostSeconds=du.toMillis()/1000;System.out.println("postNurseCo......
  • 如何将 Transformer 应用于时间序列模型
    在机器学习的广阔前景中,transformers就像建筑奇迹一样高高耸立,以其复杂的设计和捕获复杂关系的能力重塑了我们处理和理解大量数据的方式。自2017年创建第一个Transformer以来,Transformer类型呈爆炸式增长,其中包括ChatGPT和DALL-E等强大的生成式AI模型。虽然transform......
  • java8 新特性之日期时间处理 LocatDate、LocalTime、LocalDateTime、ZonedDateTime、D
    一、LocalDate、LocalTime、LocalDateTime和常用API1、LocalDatepublicvoidtest01(){//1.创建指定的日期LocalDatedate1=LocalDate.of(2021,05,06);System.out.println("date1="+date1);//2.得到当前的日期LocalDate......