时间戳与日期的相互转换 pb

1、日期转时间戳-->获取时间戳

//==============================================================================
// 函数: date2timestamp()
//------------------------------------------------------------------------------
// 描述: 获取时间戳
//------------------------------------------------------------------------------
// 参数: 
//		value	integer		
//------------------------------------------------------------------------------
// 返回值:  string
//------------------------------------------------------------------------------
// 作者:	chenzj		日期: 2021.09.02
//------------------------------------------------------------------------------
// 修改历史: 
//	
//==============================================================================

datetime ldt_dtime
date ld_today
time lt_nowtime
//ldt_dtime = today()  //gf_server_date()
ld_today =today()  // date(ldt_dtime)
lt_nowtime =now() // time(ldt_dtime)
//return String(DaysAfter( Date(1970,1,1) , Today()) *86400 +secondsafter(Time("08:00:00") ,Now()))
return String(DaysAfter( Date(1970,1,1) , ld_today) *86400 +secondsafter(Time("08:00:00") ,lt_nowtime))

2、时间戳转日期-->根据时间戳反推出时间

//==============================================================================
// 函数: timestamp2date()
//------------------------------------------------------------------------------
// 描述: 根据时间戳反推出时间
//------------------------------------------------------------------------------
// 参数: 
//		value	long al_timestamp		
//------------------------------------------------------------------------------
// 返回值:  datetime
//------------------------------------------------------------------------------
// 作者:	chenzj		日期: 2021.09.02
//------------------------------------------------------------------------------
// 修改历史: 
//	
//==============================================================================
Long ll_seconds,ll_days,ll_timestamp
ll_timestamp =al_timestamp
//判断是否为毫秒,2286年秒为10位
If Len(String(ll_timestamp)) >= 13 Then
	ll_seconds = ll_timestamp/1000
Else
	ll_seconds = ll_timestamp
End If
//天 +8 *3600,因为北京时间是从上午8点计算的
ll_days = (ll_seconds +28800 )/86400
//秒
ll_seconds = ll_seconds - ll_days * 86400
return DateTime(RelativeDate(Date(1970,1,1),ll_days),RelativeTime(Time("08:00:00"),ll_seconds))

如何对你有用,请点赞支持

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值