Articles

JavaScript and get date from timestamp

Have you ever tried to create date from timestamp using JavaScript? After some testing code I found the solution. This is what i use:

var getDateFromTimestamp = function( t )
{
    var a = new Date(t);
    
    a =
    {
        day : a.getDate(),
        month : a.getMonth() + 1,
        year :  String( a.getFullYear() ),
        hours : a.getHours(),
        minutes : a.getMinutes()
    };
	
	if( a.month < 10 )
	{
		a.month = '0' + a.month;
	}
	
	if( a.minutes < 10 )
	{
		a.minutes = '0' + a.minutes;
	}
    
    var fulldate = [a.day, a.month, a.year].join('.'),
        time = [a.hours, a.minutes].join(':');
    
    return ({
        fulldate : fulldate,
        time : time
    });
};

[......]

Read more

Let authors put line breaks (newlines) in tooltips (title attribute)

It’s seems that in Firefox 12 developers will be able to use breaks (newlines) in tooltips (title attribute). Finally.

At this moment there is no way to use new line code to break a line text in title attribute. Of course, there is some tricks to change title to your_attribute and then styling it, but unfortunately this options is poor accessibility. Screen readers may have problem with non-standard attributes. As I know.[……]

Read more

WordPress and checking if user is on home page

Sometimes we want to check if the user is on home page. This can be done by this little function. Just add this code to your functions.php and use it likt this:

if (is_homepage()){ return true; }

Source:

function is_homepage(){
    $siteurl = get_option('home');
    if ($siteurl [strlen ( $siteurl ) - 1] != '/')
    {
        $siteurl .= '/';
    }
    $self_url = sprintf ( 'http%s://%s%s', (isset ( $_SERVER ['HTTPS'] ) && $_SERVER ['HTTPS'] == TRUE ? 's' : ''), $_SERVER ['HTTP_HOST'], $_SERVER ['REQUEST_URI'] );
    
    if ([......]

Read more

Pagination