date script and a geolocation script help

by Gee S
1 replies
Hi everyone,

I'm looking for a date script and a geolocation script which I can customise. The ones I've found I'm having trouble making changes to it, i.e the size, highlighting, and colour.

Does anyone know where I can find one?

Thanks,
Gee
#date #geolocation #script
  • Profile picture of the author mojojuju
    Well first, what exactly do you want to do with this date and geolocation script?

    If you just want to print the time and the surfer's location, that can be done with a minimal amount of PHP and/or javascript. For the location part, you'll need an IP/location database, you can get one free from MaxMind - GeoLite City | Free Geolocation Database

    I guess what I'd like to say is that you don't really need an elaborate script for this, and that all you need to print the date with PHP is this:

    PHP Code:
    <?php
    print strftime('%c');
    ?>
    That's really all you need to do to get the date in PHP, you can customize the format for instance if you want just the month, day, and year. And then any style changes like color or font can be done by CSS.

    As far as the Geolocation, if you have Maxmind's database and their Apache module on your server, printing out the location is really easy too, like this:

    PHP Code:
    <?php
    print strftime('%c');

    $city apache_note("GEOIP_CITY");
    $stateORregion apache_note("GEOIP_REGION");
    echo 
    '<br />';
    echo 
    'It looks like you\'re from '.$city.', '.$stateORregion;
    ?>

    As you see, it takes really little code, and any styling can be done by surrounding the output information with <span>'s or <div>'s along with a class attribute and some CSS to style it.

    Now, I don't know about your web host, but if they can install the maxmind apache module that would be good. There is a PHP class that can be used to get the location, but doing it the apache way is much faster.
    Signature

    :)

    {{ DiscussionBoard.errors[1735155].message }}

Trending Topics