Avatar of Pete C
Pete CFlag for United States of America

asked on 

convert timestamp integer to localtime string in php

Hi - I would like to convert a timestamp integer to a localtime string.  If the input was a timestamp string (rather than an integer), I could use the datetime object as noted below.


// set object
$date = new DateTime($utc_timestamp, new DateTimeZone($utc_timezone));


// change to local timezone and create output
$date->setTimezone(new DateTimeZone($localtimezone));

$localtimestamp = $date->format('Y-m-d H:i:s');


I am sure that there is a simple solution that I am unaware of, I look forward to your insights, thanks!


Pete

PHP

Avatar of undefined
Last Comment
Pete C
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Pete C
Pete C
Flag of United States of America image

ASKER

thanks Julian, that is easy enough!
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo