Converting date in PHP from yyyymmdd to yyyy mm dd format

December 12th, 2011

I have dates in the following format (yyyymmdd, 18751104, 19140722) and i need normal date (yyyy mm dd, 1875 11 04, 1914 07 22).

1. first you can use strtotime and date functions (this will fail with dates before the Unix epoch at the start of 1970. )
<?php
// prints 1995 Oct 12
echo date("Y M d", strtotime("19951012"));
?>

2. Alternative which will work with dates before 1970
<?php // Returns the year as an offset since 1900, negative for years before
$parts = strptime("18951012", "%Y%m%d");
$year = $parts['tm_year'] + 1900; // 1895
$day = $parts['tm_mday']; // 12
$month = $parts['tm_mon']; // 10 ?>

3. simple method – date_parse_from_format

<?php $parsed_date = date_parse_from_format('Ymd', $date); ?> 

4. substr because it’s probably the lightest way to do it

mktime(substr($date, 0, 4), substr($date, 4, 2), substr($date, 6, 2));

Delete default input value on click

November 18th, 2011

I hate this task: “Delete default value of an input text on click“. Many times i use code like this

<input type="text" value="email@email.com" name="email"
onblur="if (this.value == '') {this.value = 'email@email.com';}"
onfocus="if (this.value == 'email@email.com') {this.value = '';}" />

Forget about this! I would recommend you try HTML5 solution below which uses the placeholder attribut.

<input name="Email" type="text" value="" placeholder="email@email.com" />

Friendly and high quality fuel

November 16th, 2011

How do you heat your home? If that is wood pellets – you are about to visit the right place www.greenpellets.nl. The goal of the project is to provide Dutch people with environmentally friendly and high quality fuel for pocket friendly prices. More to come.

Google+ launches Pages for businesses

November 8th, 2011

Google opened up Google+ to business.

It’s calling Google+ Pages. Google+ Pages appears to be little difference between a Page and an individual account.
You’re able to add Pages to any of your regular Circles. Page owners are able to post and take part in Hangouts.
Pages turn up in Google search results. Company’s introduced a new Direct Connect and lets you search specifically for Google+ Pages.
Both features are rolling out starting today.

P.S. my first google+ page MediaArt

Grand Theft Auto V – Trailer – 11/02/11

November 2nd, 2011

about nerds

October 28th, 2011

I visited with my boss, and a client whose website I’m going to do. The client had met my boss before, but not me. So, my boss introduced me:

Boss: Well, this is the guy who’s doing your website, Bob.
Client: Hi there! So you’re the nerd, right?

 

from: clientsfromhell.net

Adobe Photoshop CS6

October 26th, 2011

Today found nice torrent – “Adobe Photoshop CS6 v13.0 Pre Release Incl Keymaker-CORE “.
After search of new features I watch nice video:

and some fake video to:

Will check more new future from CS6 and post here.

How to find all large files on a Linux machine

October 12th, 2011

Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:
find . -size +20000k -exec du -h {} \;

Google Dart V.S. JavaScript

October 11th, 2011

A technical overview on the Dart language site,

“Dart programmers can optionally add static types to their code. Depending on programmer preference and stage of application development, the code can migrate from a simple, untyped experimental prototype to a complex, modular application with typing. Because types state programmer intent, less documentation is required to explain what is happening in the code, and type-checking tools can be used for debugging.”

Google notes that with existing languages, the developer is forced to make a choice between static and dynamic languages. Traditional static languages require heavyweight tool chains and a coding style that can feel inflexible and overly constrained.

Google further explained the design goals for Dart by describing the issues web developers face today:
Small scripts often evolve into large web applications with no apparent structure—they’re hard to debug and difficult to maintain. In addition, these monolithic apps can’t be split up so that different teams can work on them independently. It’s difficult to be productive when a web application gets large.

Scripting languages are popular because their lightweight nature makes it easy to write code quickly. Generally, the contracts with other parts of an application are conveyed in comments rather than in the language structure itself. As a result, it’s difficult for someone other than the author to read and maintain a particular piece of code.

Google + API

September 16th, 2011

Today, Google launching the first version of the Google+ APIs.

This API release is public data only — it lets you read information that people have shared publicly on Google+.

Note: The Google+ API currently provides read-only access to public data. All API calls require either an OAuth 2.0 token or an API key.

I wait for this API 2 month and it’s only read only service :(.

We’ll have to wait longer for full Google + API.

Next »