Author Topic: Playing with date in detail.html/php  (Read 22246 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Playing with date in detail.html/php
« on: November 08, 2007, 11:57:59 PM »
Hi guys,

I have the hole day problems with my gallery and now I have to solve something difficult for me:

I add two image additional fields:
{date_start} and {date_end}
Both are working fine on details.html

First question:
I want to add a new array {date2}
{date2}= {date_end} - {date_start}
I want the answer in days

Second question:
I want to add a new array {date3}
{date3}= today - {date_start}
I want the answer also in days

It is now midnight and I can not sleep because this issue. :cry:

Many thanks in advance for any help and/or explain,
Cruxy

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #1 on: November 09, 2007, 12:25:07 AM »
You need edit includes/functions.php file for this in show_image function ...
Please post all additional image fields name with request (date start, date end) and I code. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #2 on: November 09, 2007, 12:30:32 AM »
Thank you Thunderstrike,

Here we go:

The image additional fields are already exist:
{date_start} and {date_end}

So I want a new array
{date2}= {date_end} - {date_start} (days, for example: 30 days)

I want also:
{date3}= today - {date_start} (days, for example: 30 days)

Thank yoy in advance,
Cruxy


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #3 on: November 09, 2007, 12:33:44 AM »
Ok now ... what field type is date start and end ? (int, date) ? Please post more detail with this ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #4 on: November 09, 2007, 12:42:06 AM »
Oke,
{date_end} and {date_start}  are both are type date (I can change it if you want to).


Do you need more info? :)
« Last Edit: November 09, 2007, 10:16:57 AM by cruxy »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #5 on: November 09, 2007, 01:03:34 AM »
// Step 1

In details.php file,

find:

Quote
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

add before:

Code: [Select]
if (isset($image_row['date_start']) && !empty($image_row['date_start']) && isset($image_row['date_end']) && !empty($image_row['date_end'])) {
    $image_start_date = $image_row['date_start'];
    $image_end_date = $image_row['date_end'];
    if (preg_match("/(\d{2})-(\d{2})-(\d{4})/", $image_start_date, $start)) {
        if (preg_match("/(\d{2})-(\d{2}-(\d{4}))/", $image_end_date, $end)) {
            if ($start[1] > date("d")) {
                $image_real_date_today = $start[1] - date("d");
            } elseif ($start[1] < date("d")) {
                $image_real_date_today = date("d") - $start[1];
            } elseif ($start[1] == date("d")) {
                $image_real_date_today = $start[1];
       
            } elseif ($end[1] > date("d")) {
                $image_real_date_today = $end[1] - date("d");
            } elseif ($end[1] < date("d")) {
                $image_real_date_today = date("d") - $end[1];
            } elseif ($end[1] == date("d")) {
                $image_real_date_today = date("d") - $end[1];           
            }
            $image_real_date_end_start = $end[1] - $start[1];
        }
    }
}

// Step 1.1

Find:

Quote
"lang_file_size" => $lang['file_size'],

add after:

Code: [Select]
"date2" => (isset($image_real_date_end_start)) ? $image_real_date_end_start : "",
"date3" => (isset($image_real_date_today)) ? $image_real_date_today : "",

In details.html file, use: {date2} and {date3} .
« Last Edit: November 09, 2007, 12:24:37 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #6 on: November 09, 2007, 01:12:04 AM »
Sorry, I fix post. You no work with int but date. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #7 on: November 09, 2007, 01:29:06 AM »
Hi Thunderstrike,

It did not works yet!!!

There is something wrong with the date.
In edit image I put 01-10-2007 but in details.htm I get 0000-00-00
and when I put 2007-10-01 I get 2007-10-01.
I want to use actually 01-10-2007.
How can I change the format of date? :roll:

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #8 on: November 09, 2007, 01:31:00 AM »
Quote
How can I change the format of date?

Re-create date start and date end with int type. No with date field.  :mrgreen:
I fix post in some min ...

[edit] - I fix for show with int microtime field. If set date in microtime - is quick way. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #9 on: November 09, 2007, 01:49:54 AM »
Hi Thunderstrike, I don't understand you. Have you already updated the code or do I have to wait :roll:

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #10 on: November 09, 2007, 02:15:47 AM »
The code is update but you need add date (start and end) with microtime. Same way image_date is inject. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #11 on: November 09, 2007, 02:52:07 AM »
Ok, I find other. What is date format in ACP - > Setting you have ? (Ex: d-m-Y) ...
If say format, I can code. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #12 on: November 09, 2007, 03:24:01 AM »
Ok, I edit code for step 1. Date format is: Y-m-d . If is no right - is ok - I edit. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #13 on: November 09, 2007, 10:49:43 AM »
Hi Thunderstrike,
Here we go again  :D

I can not test the code because we have to solve first the problem of showing the dates on the details.
I will explain:

The additional field {date_start} = 01-10-2007 (At the edit image "ACP")
On the details.html is showing only 1
On the database I used: int(11) NO 0 (The same as {image_hits}).

I do not understand why? :roll:
See screenshots

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #14 on: November 09, 2007, 12:26:03 PM »
Quote
The additional field {date_start} = 01-10-2007 (At the edit image "ACP")

Ok, so I fix date format in code now. ;)

Quote
On the database I used: int(11) NO 0 (The same as {image_hits}).

Oh ... this is right ... create the date_start and date_end field with date again. I miss for say this after last fix. :oops:
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?