Convert Google Anyltics API date of the visit

on with Leave a reply

While using Google Analytic API to get the unique visitors and date, I got date in funky format. I thought date is return as time. So I tried convert it in php  echo date(‘Y-m-d’,’20130811′). I only got wired date. After that I just look into the google documents and I realized date is in integer in the format YYYYMMDD.

The date of the visit. An integer in the form YYYYMMDD.

So just write a code to convert the date in proper format

        $datestring = '20130811';

        $year = substr($datestring,'0',4);
        $month = substr($datestring,4,2);
        $day = substr($datestring,6,2);
        echo $date = $year.'-'.$month.'-'.$day;


Posted on by .

About Gowri

I am professional web developer with 8+ years experience. PHP, jQuery, WordPress, Angular and Ionic are my key skills in web development. I am working with strong enthusiastic team with spirit. We provide all web related solution like HTML/CSS development, Web graphic design and Logo.

Leave a Reply

Your email address will not be published. Required fields are marked *