phorcon3 Posted February 8, 2008 Share Posted February 8, 2008 <?php $timestamp = time(); ?> and let's say this equals to 1202482743 <?php echo date('F j, Y @ g:i A', 1202482743); ?> which then equals to February 8, 2008 @ 3:59 PM but how could i transform the unix timestamp (1202482743) so it would output February 8, 2008 @ 12:00 AM ..so it's the beginning of the day? i can only think of a really stupid way to do it, and that would be it <?php $timestamp = time(); $month = date('n', $timestamp); $day = date('j', $timestamp); $year = date('Y', $timestamp); echo date('F j, Y @ g:i A', mktime(0,0,0,$month,$day,$year)); ?> can anyone else think of a better way to do it? Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/ Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 You need to round it to something like 1202480000 note: this is a guess method that might work. Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461774 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 What's wrong with echo date('F j, Y', 1202482743)." @ 12:00 AM"; Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461777 Share on other sites More sharing options...
phorcon3 Posted February 8, 2008 Author Share Posted February 8, 2008 because i have to compare it to something.. its gotta be between a certain timeframe Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461781 Share on other sites More sharing options...
PFMaBiSmAd Posted February 8, 2008 Share Posted February 8, 2008 mktime(0,0,0,$month,$day,$year) is actually the best available method. The strtotime() function can probably do it, but there is a general lack of documentation about what special operators it has available. Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461792 Share on other sites More sharing options...
phorcon3 Posted February 8, 2008 Author Share Posted February 8, 2008 oh, alright ..thanks Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461846 Share on other sites More sharing options...
laffin Posted February 8, 2008 Share Posted February 8, 2008 simple convert timestamp to date string without time portion so it's a date, convert this into a timestamp. (this can be done initially as well, so timestamp never has the time information). <?php $timestamp = 1202482743; $startofday = strtotime(date("Y-m-d",$timestamp)); echo date('F j, Y @ g:i A',$startofday); ?> Link to comment https://forums.phpfreaks.com/topic/90060-solved-unix-timestamp/#findComment-461906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.