Skip to content
Advertisement

Tag: timestamp

PHP Compare 2 Timestamps Logic

I’m working with an API that generates a token that I use for subsequent requests that is valid for 15 minutes. I’m storing a timestamp when the token is first generated and adding 15 minutes to this and storing that as a session variable like this: When I make a subsequent call to the API I’m checking to see if

Add minutes to time based on current time

I am trying to figure out a way to change a value based on current time, currently I am using the following code to add certain minutes the time the order is placed. which is working fine (except for $minutes_to_add = 170 is only adding only 30 minutes to the current time for some reason but I am living with

Convert timestamp with dots in PHP (“yyyy.mm.dd hh:nn:ss.zzz”)

I’m trying to convert strings with hungarian datetime format, but no success because of the dot-separators: Isn’t it possible without “string-replace” like this: strtotime(preg_replace(“/([0-9]{4}).([0-9]{2}).([0-9]{2})/”,’${1}-${2}-${3}’,$xml->delivery_time)) ? (I’m new to PHP 5 and I’m shocked it can not simply convert a common date format. Searched 200+ results, wasted 4+ hours … no success.) Answer This solution will also work for PHP versions

Datetime to Timestamp in milliseconds in PHP

I would like to create a timestamp in milliseconds from the input ‘2016-03-22 14:30’. Also the timezone specified should be Australia/Sydney. I’ve tried different approaches but none seem to be working. Can anyone help me please? I’m really struggling with that. Answer Pretty self explanatory code, so I wont say much. If you want to display it properly.

Advertisement