xoops forums

timgno

Module Developer
Posted on: 2016/6/3 17:11
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#1

strtotime in edit mod

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?

zyspec

Module Developer
Posted on: 2016/6/3 19:23
zyspec
zyspec (Show more)
Module Developer
Posts: 1042
Since: 2004/9/21
#2

Re: strtotime in edit mod

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)?

timgno

Module Developer
Posted on: 2016/6/3 20:16
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#3

Re: strtotime in edit mod

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/viewto ... id=360272#forumpost360272

The variables are correct in strtotime

zyspec

Module Developer
Posted on: 2016/6/4 22:13
zyspec
zyspec (Show more)
Module Developer
Posts: 1042
Since: 2004/9/21
#4

Re: strtotime in edit mod

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)?

timgno

Module Developer
Posted on: 2016/6/5 7:46
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#5

Re: strtotime in edit mod

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


On all modules

timgno

Module Developer
Posted on: 2016/6/5 18:37
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#6

Re: strtotime in edit mod

Why, now marks a day before?

Really strange!

Mamba

Moderator
Posted on: 2016/6/5 20:16
Mamba
Mamba (Show more)
Moderator
Posts: 10770
Since: 2004/4/23
#7

Re: strtotime in edit mod

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

timgno

Module Developer
Posted on: 2016/6/5 22:18
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#8

Re: strtotime in edit mod

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/viewto ... 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']));

timgno

Module Developer
Posted on: 2016/6/5 22:42
timgno
timgno (Show more)
Module Developer
Posts: 1504
Since: 2007/6/21
#9

Re: strtotime in edit mod

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;
        }

Mamba

Moderator
Posted on: 2016/6/6 2:37
Mamba
Mamba (Show more)
Moderator
Posts: 10770
Since: 2004/4/23
#10

Re: strtotime in edit mod

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