PHP Warning: mysql_query(): Access denied for user 'vhelpf'@'localhost' (using password: NO) in ..../includes/class_postbit.php(265) : eval()'d code on line 2

PHP Warning: mysql_query(): A link to the server could not be established in ..../includes/class_postbit.php(265) : eval()'d code on line 2

PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ..../includes/class_postbit.php(265) : eval()'d code on line 3

PHP Warning: mysql_query(): Access denied for user 'vhelpf'@'localhost' (using password: NO) in ..../includes/class_postbit.php(265) : eval()'d code on line 2

PHP Warning: mysql_query(): A link to the server could not be established in ..../includes/class_postbit.php(265) : eval()'d code on line 2

PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ..../includes/class_postbit.php(265) : eval()'d code on line 3
Looking for a date/time formating function - Vista Help Forum

Go Back   Vista Help Forum » Web Design & Development » Programming
Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2007
cpearson's Avatar
cpearson cpearson is offline
Agent - Level 3
 
Join Date: Dec 2006
Posts: 281
cpearson is on a distinguished road
Default Looking for a date/time formating function

I am looking for a function to convert a date and time to a "pretty print" format like the format this forum displays.

11 minutes ago
6 hours ago
2 days ago
1 week ago

The function would have to find the difference in the current date/time and the passed data/time value. Then it would have to test for minute(s),hour(s),day(s),week(s) cases. I am too lazy to write this function so if you know a good one post it here. Before anyone asks, I looked through vbulletin (this system) code but gave up.
Reply With Quote
  #2  
Old 01-29-2008
awesomo awesomo is offline
Member - Class 3
 
Join Date: Jan 2007
Posts: 114
awesomo is on a distinguished road
Default

Here is a function from Pure-Esssence.net that will calculate the time diff. from now to a given timestamp.

http://pure-essence.net/2005/05/05/t...-php-function/

Code:
/* returns an array of [days],[hours],[minutes],[seconds] time left from now to timestamp given */ 
function timeleft($time_left=0, $endtime=null) { 
	if($endtime != null) 
		$time_left = $endtime - time(); 
	if($time_left > 0) { 
		$days = floor($time_left / 86400); 
		$time_left = $time_left - $days * 86400; 
		$hours = floor($time_left / 3600); 
		$time_left = $time_left - $hours * 3600; 
		$minutes = floor($time_left / 60); 
		$seconds = $time_left - $minutes * 60; 
	} else { 
		return array(0, 0, 0, 0); 
	} 
	return array($days, $hours, $minutes, $seconds); 
}


Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random 'date modified' changes shiningstar Vista Help Forum 0 08-30-2010 10:39 AM
Sorting folders by date taken joyful Vista Help Forum 3 05-22-2010 08:40 PM
Currency Gadget out of date AusVista Vista Gadgets 13 09-06-2009 06:44 AM
Vista time/date problem. 452008 Vista Help Forum 0 04-05-2008 03:35 AM
Sorting files by date pigfox Vista Help Forum 2 07-24-2007 02:46 PM