1
timgno
strtotime in edit mod
  • 2016/6/3 17:11

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Why, when I go to save an edited content, then it reset the date to zero with strtotime?

The result is obvious this 1/1/1970

To save the new content regularly.

Is a topic already discussed?

2
zyspec
Re: strtotime in edit mod
  • 2016/6/3 19:23

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


This is generally caused by an invalid value passed to the strtotime() function. If it doesn't understand it (or it's zero) then strtotime will return the epoch time (1/1/1970).

Where are you having a problem (module, XOOPS core, etc)?

3
timgno
Re: strtotime in edit mod
  • 2016/6/3 20:16

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Quote:

zyspec wrote:
This is generally caused by an invalid value passed to the strtotime() function....


I think the problem is in the language constant, now it works after I modified this:

https://xoops.org/modules/newbb/viewtopic.php?post_id=360272#forumpost360272

The variables are correct in strtotime

4
zyspec
Re: strtotime in edit mod
  • 2016/6/4 22:13

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


It looks like the reason it works after you change the globals.php defines is because you're eliminating some of the information (H:m:s) so then strtotime() can process it.

Which module (or XOOPS function/method) is having a problem before you change the DATESTRING(s)?

5
timgno
Re: strtotime in edit mod
  • 2016/6/5 7:46

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Quote:
Which module (or XOOPS function/method) is having a problem before you change the DATESTRING(s)?


On all modules

6
timgno
Re: strtotime in edit mod
  • 2016/6/5 18:37

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Why, now marks a day before?

Really strange!

7
Mamba
Re: strtotime in edit mod
  • 2016/6/5 20:16

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Quote:
Why, now marks a day before?


You need to decide what you want:

a) people feel sorry for you?
b) people to help you?



If the second, provide more information:

- Which module?
- how does it happen? (what do you enter, what do you expect, what do you get?)
- can your reproduce it?

More details, unless you don't expect any help, just want to complain, so you feel better!
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

8
timgno
Re: strtotime in edit mod
  • 2016/6/5 22:18

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Quote:
Mamba wrote:
a) people feel sorry for you?
b) people to help you?


I show you what happens to me...

I modified the constants like this:

https://xoops.org/modules/newbb/viewtopic.php?post_id=360272#forumpost360272

Today is 06/06/2016

While I get this 05/06/2016 when I use formtextdateselect

Because I want to display the date in this format dd/mm/yyyy with (d/m/Y)

The code of the class formtextdateselect was only replaced the constant _DATESTRING_M

Instead of writing in constant (j/m/Y), I changed to (d/m/Y)

This is a new module events

The variable appears to be correct, I did a lot of testing

$eventsObj->setVar('event_date'strtotime($_POST['event_date']));

9
timgno
Re: strtotime in edit mod
  • 2016/6/5 22:42

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Sorry,

I think have forgotten that I used formatTimeStamp with a new constant

but in reality the function is missing that I created again:

switch ($format) {
            case 
's':
                
$datestring _SHORTDATESTRING;
                break;

            case 
'm':
                
$datestring _MEDIUMDATESTRING;
                break;

            case 
'mysql':
                
$datestring 'Y-m-d H:i:s';
                break;

            case 
'l':
                
$datestring _DATESTRING;
                break;

            case 
'c':
            case 
'custom':
                static 
$current_timestamp$today_timestamp$monthy_timestamp;
                if (!isset(
$current_timestamp)) {
                    
$current_timestamp xoops_getUserTimestamp(time(), $timeoffset);
                }
                if (!isset(
$today_timestamp)) {
                    
$today_timestamp mktime(000date('m'$current_timestamp), date('d'$current_timestamp), date('Y'$current_timestamp));
                }

                if (
abs($elapse_today $usertimestamp $today_timestamp) < 24 60 60) {
                    
$datestring = ($elapse_today 0) ? _TODAY _YESTERDAY;
                } else {
                    if (!isset(
$monthy_timestamp)) {
                        
$monthy_timestamp[0] = mktime(00000date('Y'$current_timestamp));
                        
$monthy_timestamp[1] = mktime(00000date('Y'$current_timestamp) + 1);
                    }
                    
$datestring _YEARMONTHDAY;
                    if (
$usertimestamp >= $monthy_timestamp[0] && $usertimestamp $monthy_timestamp[1]) {
                        
$datestring _MONTHDAY;
                    }
                }
                break;

            default:
                
$datestring _DATESTRING;
                if (
$format != '') {
                    
$datestring $format_copy;
                }
                break;
        }

10
Mamba
Re: strtotime in edit mod
  • 2016/6/6 2:37

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


The issue with dates is very, very tricky, because almost every module has its own "creative" solution on how to deal with dates and zones. Because of that I would not touch any date issues.

Some individual modules had some issues in the past, but this has been pretty much resolved, and lately we haven't hear any issues. Please review some of the old posts related to dates in News, NewBB, extCal, etc.

In XOOPS 2.6.0 Richard plans to standardize it on common set of rules. Till the, I would suggest not to change anything, unless is really broken in a particular module.

As since you're saying that the problem is in "all" modules, I suspect that this is not a XOOPS problem, but more a solution that you would like to implement but which doesn't work in all modules, because of the above mentioned richness of "date/time solutions" in individual modules.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Login

Who's Online

211 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 211


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits