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

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #15 on: November 09, 2007, 12:48:01 PM »
No problem :)

I still can not test the code because when I changed int to date I get the date of {date_start}  like: 0000-00-00 instead of 01-10-2007
I am testing on a very fresh gallery
« Last Edit: November 09, 2007, 01:23:39 PM by cruxy »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #16 on: November 09, 2007, 12:51:17 PM »
Quote
I still can not test the code because when I changed int to date  I get the date of {date_start}  like: 0000-00-00 instead of 01-10-2007

Please decide the date format range. Is year before or year after ?
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 #17 on: November 09, 2007, 12:54:24 PM »
I want to use    :arrow: 01-10-2007
What strange is that {image_date} workt perfect even you edit the date, but the date of the additional field NOT
« Last Edit: November 09, 2007, 01:23:19 PM by cruxy »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #18 on: November 09, 2007, 12:58:58 PM »
I want to use    :arrow: 01-10-2007

Ok so date format is correct. ;)

What strange is that {image_date} workt perfect even you edit the date, but the date of the additional field NOT :roll:

image_date is create with int.

For additional field, is create with int or with date ? Is no matter for me but you need say ...
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 #19 on: November 09, 2007, 01:14:59 PM »
The additional field {hits_start} is created with DATE "Type: Date, Null: No" (as you asked me to do).

Quote
Ok so date format is correct.
On details is date 0000-00-00 is not correct. First the format is not good and second I see only zero's instead of 01-10-2007

Something wrong with the DATE additional fields? or in the database? :?:

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #20 on: November 09, 2007, 01:21:14 PM »
Quote
On details is date 0000-00-00 is not correct. First the format is not good and second I see only zero's instead of 01-10-2007 :roll:

Please STOP use roll eyes :!:

Now, is say you see format with year before. You no use my fix. Use it. I say in last post - I fix my code for year at end. Year in code is now: d-m-Y

Quote
Something wrong with the DATE additional fields? or in the database?

Nothing is wrong with database ... you add date in field ? If see 00-00-0000 (or 0000-00-00 if no use my fix), is mean you no add nothing in field. Field is empty. :?
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 #21 on: November 09, 2007, 01:32:46 PM »
Quote
Please STOP use roll eyes
Oh sorry I did not mean that!

Quote
Nothing is wrong with database ... you add date in field ? If see 00-00-0000 (or 0000-00-00 if no use my fix), is mean you no add nothing in field. Field is empty.

I am trying to figuur out the problem of the database. I go back to you when I find something :?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #22 on: November 09, 2007, 01:44:01 PM »
Database is fine. You need for set date (is good if create with DATE field type in phpmyadmin) and set correct date in ACP - > Images - > Edit images page for image you click.

1 - Submit form and server is process date.
2 - Check for see if still 00-00-0000 for return value.
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 #23 on: November 09, 2007, 01:55:32 PM »
I think I have the unswer but NOT the solution.

In phpmyadmin I created a date. Everything is fine till now because the right date is showing in the details.
BUT when I tried to open this image in ACP, the date changed to 0000-00-00.
Now we know for sure that nothing wrong with the database. There is a miscommunication between {hits_start} (Additional field) and the database.

I beleave that the database doesn't understand that {hits_start} is a date!
Maybe we have to change or to add something in function.php?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #24 on: November 09, 2007, 02:10:37 PM »
Good news :)
The problem is solved, but I still get the format: 2007-10-01. (phpmyadmin does not accept the format 01-10-2007)
How can I change it?
NOTE: When I we change the format I will start test in you code!

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Playing with date in detail.html/php
« Reply #25 on: November 09, 2007, 02:32:02 PM »
I did some research via GOOGLE and finaly I have the unswer.

phpmyadmin have problems with dates, so it accecpt only this format: 0000-00-00 (INPUT).
But if you want to show the format 00-00-0000 (OUTPUT) you need to use:

1 - The explode function on each date in your file and then just insert into the mysql table in the format yyyy-mm-dd.

OR
<?php
$myinput='12/15/2005';
$sqldate=date('Y-m-d',strtotime($myinput));
echo $sqldate;
?>

PS: I tried to figure out how the 4images shows the format 00-00-0000, but no luck yet!!!

Can you help me in that?

Many thanks in advance,
Cruxy

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #26 on: November 09, 2007, 02:33:51 PM »
This is in 4images with format_date function so use:

Code: [Select]
$image_start_date = format_date($config['date_format'], $image_row['date_start']);
$image_end_date = format_date($config['date_format'], $image_row['date_end']);
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 #27 on: November 09, 2007, 02:56:56 PM »
I am still fighting to make it work.

Quote
$image_start_date = format_date($config['date_format'], $image_row['date_start']);
$image_end_date = format_date($config['date_format'], $image_row['date_end']);

I did not test the first code yet, because I want to change first the format of {date_start} on the details.
Listen, On functions.php I added this line:

"date_start" => format_date($config['date_format']." ".$config['time_format'],$image_row['date_start']), under
 
"image_date" => format_date($config['date_format']." ".$config['time_format'],$image_row['image_date']),

NO format changing yet!!!

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Playing with date in detail.html/php
« Reply #28 on: November 09, 2007, 03:00:17 PM »
If want to use date_start and date_end with strtotime, you need set field by int and no by date for keep right date format with 4images.
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 #29 on: November 09, 2007, 04:45:50 PM »
Believe it or not. I was busy with this matter since this morning. I tried all tricks, but no luck yet!
I could not change the format of the {date_start}, but it is not very important at the moment.

Here we go again:
{date_start} and {date_end} are TYPE: Date.
The dates are showing in the details.html, but {date2} and {date3} NOT!!!
Do you have to change/add something in the code?
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];
        }
    }
}

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

See screenshot please!