Jump to content

I like to know how to change date format from (2006-07-02) to 02-07-2006


Recommended Posts

Hi

I like to now or more to the point shown how to convert my date from (2006-07-02) to 02-07-2006 on my display page.

Here is the code below. Date is listed in the <td >($listed)</td>

As is date is shown on the page as  (2006-07-02)

Thanks for your kind help.

[code]function publicstats_install_addon() {
    }
    function publicstats_show_admin_icons() {
    }
    function publicstats_load_template() {
        $template_array = array('addon_publicstats_link', 'addon_publicstats_page');
        return $template_array;
    }
    function publicstats_run_action_user_template() {
        switch ($_GET['action']) {
            case 'addon_publicstats_page':
            $data = publicstats_display_addon_page();
            break;
            default:
            $data = '';
            break;
        } // End switch ($_GET['action'])
        return $data;
    }
    function publicstats_run_action_admin_template() {
        switch ($_GET['action']) {
            case 'addon_publicstats_admin':
            $data = publicstats_display_admin_page();
            break;
            default:
            $data = '';
            break;
        } // End switch ($_GET['action'])
        return $data;
    }
    function publicstats_run_template_user_fields($tag = '') {
        switch ($tag) {
            case 'addon_publicstats_page':
            $data = publicstats_display_addon_page();
            break;
            case 'addon_publicstats_link':
            $data = publicstats_display_addon_link();
            break;
            default:
            $data = '';
            break;
        } // End switch ($_GET['action'])
        return $data;
    }
   
    // Addon Specific Function
    function publicstats_display_addon_link() {
        $display = '<li><a href="index.php?action=addon_publicstats_page">Stats</a></li>';
        return $display;
    }
    function publicstats_display_addon_page() {
        global $conn, $config, $lang, $count, $num_of_listings, $table_border;
        require_once($config['basepath'].'/include/misc.inc.php');
        $misc = new misc();
// start our display in a table
        $display = "<table border=\"0\" width=\"100%\" id=\"table1\">
<tr>
<td><u><strong>Listing Titles</strong></u> </td>
<td align=\"center\"><u><strong>Seller ID</strong></u> </td>
<td><u><strong>Listed On</strong></u></td>
<td><u><strong>Price</strong></u> </td>
<td align=\"center\"><u><strong>Viewed</strong></u> </td>
</tr>";
        $count = 0;
        $sql = "SELECT * FROM en_listingsdb WHERE listingsdb_active = 'yes' ORDER BY listingsdb_hit_count DESC LIMIT 0 , 30";
        $recordSet = $conn->Execute($sql);
        if ($recordSet === false) {
            $misc->log_error($sql);
        }
        while (!$recordSet->EOF) {
            $id = $misc->make_db_unsafe($recordSet->fields['listingsdb_id']);
            $title = $misc->make_db_unsafe($recordSet->fields['listingsdb_title']);
            $agent = $misc->make_db_unsafe($recordSet->fields['userdb_id']);
            $hits = $misc->make_db_unsafe($recordSet->fields['listingsdb_hit_count']);
    $listed = $misc->make_db_unsafe($recordSet->fields['listingsdb_creation_date']);

    // Get the Price from the listingsdbelements table
    $sql1 = "SELECT listingsdbelements_field_value FROM ".$config['table_prefix']."listingsdbelements WHERE listingsdbelements_field_name = 'price' AND listingsdb_id = '$id'";
            $recordSet1 = $conn->Execute($sql1);
if ($recordSet1 === false)
{
$misc->log_error($sql1);
}
$Price = $misc->make_db_unsafe ($recordSet1->fields['listingsdbelements_field_value']);
            # VISABLE LINKS AND TEXT #
$display .= "<tr>
<td><a href=\"index.php?action=listingview&listingID=$id\">$title</a> </td>
<td align=\"center\"><a href=\"index.php?action=view_user&user=$agent\">$agent</a> </td>
<td >($listed)</td>
<td>$ $Price</td>
<td align=\"center\">($hits)</td>
</tr>
";
            //$display .= "<a href=\"index.php?action=view_user&user=$agent\">Agent Number $agent</a> Owns The listing <a href=\"index.php?action=listingview&listingID=$id\">$title</a> has been viewed  ($hits) Times<br>";
            # END VISABLE LINKS AND TEXT #
            $recordSet->MoveNext();
        } // end while
$display .= "</table><br/>";
        return $display;
    }
    // Addon Specific Function
    function publicstats_display_admin_page() {
        $display = 'This is a Addon page';
        return $display;
    }
   
?>
[/code]
Hi Orio,

thanks for your help and it's really appreciated.

I am not familiar with use of functions. In order to use it,  would I use the function just before  the $listed = $misc->make_db_unsafe($recordSet->fields['listingsdb_creation_date']); statement ?

Can you please tell me how I could use within my code please?
You can also use a combination of the date() and strtotime() functions. In your case:
[code]<?php
$display .= "<tr>
<td><a href=\"index.php?action=listingview&listingID=$id\">$title</a> </td>
<td align=\"center\"><a href=\"index.php?action=view_user&user=$agent\">$agent</a> </td>
<td>(" . date('d-m-Y',strtotime($listed)) . ")</td>
<td>$ $Price</td>
<td align=\"center\">($hits)</td>
</tr>
";?>[/code]

Ken
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.