开发者

generate unix timestamp from last time

开发者 https://www.devze.com 2022-12-28 09:03 出处:网络
suppose i have one column in mysql database which is stated last time one equipment is up in h:i:s format (ex: 00:05:11) or 1d21h, means that the equipment is on since 5 min before, what is the best m

suppose i have one column in mysql database which is stated last time one equipment is up in h:i:s format (ex: 00:05:11) or 1d21h, means that the equipment is on since 5 min before, what is the best method i can convert this to unix timestamp, say if using php script how? or direct convert last unix timestamp using mysql function query.

actually, i want to calculate for start time for this equipment uptime in unix timestamp where i have one column in mysql startcapture that will be deducted with last column to get start time. so starttime = startcapture - last (this last time that has to开发者_开发知识库 convert to unix timestamp based on now() - h:i:s ). but the problem is sometimes the format change from h:i:s to ex: 1d22h, if h:i:s means the equipment is up since ex: 00:05:11 min before and if 1d22h means the equipment already up 1 day 22 hours before.

so the main things here is to convert last column to appropriate unix timestamp.

please help guys, asap.

update:

simplified like this,

i want to display the start time, that can only be calculate by deducting startcapture column with last column,

startcapture column in unix timestamp, while the last column in h:i:s format sometimes in 1d22h format (means the equipment is already up since 1 day 22 hour or since 00:05:11, hours minute seconds)

the only things I want is to convert last column into unix timestamp which is time() - (00:05:11 or 1d22h),

is there any specific function?


If you have the time parsed into variables then you can use mktime to get the timestamp: http://www.php.net/manual/en/function.mktime.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号