gocodebox / gocodebox/lifterlms
Events: client and server event's dates are not saved with the same timezone.
- Dominant language
- PHP
- Stars
- 212
- Forks
- 140
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 19
Description
### Reproduction Steps
+ Set WP timezone to something different than php local time.
+ Produce a server side event, like sign-in/sign-out -> check the db entry date: set in the wp timezone
+ Now produce a client side event - e.g. start a video (with the advanced-videos add-on) - and persist it in the db (e.g. exit the page).
### Expected Behavior
+ Both client and server side dates should be saved using the same time zone.
### Actual Behavior
+ Client side events date is saved using php local time (php [`date()`](https://github.com/gocodebox/lifterlms/blob/2d86dd2c67042b1f3bfb9a63d0b7b2089e8eaa28/includes/class-llms-events.php#L152) to which we pass a [GMT timestamp](https://github.com/gocodebox/lifterlms/blob/4.19.0/assets/js/app/llms-tracking.js#L141)) while server side events are saved using [wp local time](https://github.com/gocodebox/lifterlms/blob/4.19.0/includes/abstracts/llms.abstract.database.store.php#L115)
The difference can be quite important as the first is usually a server setting the users are not going to change.
At the moment this impacts on the [idle sessions](https://github.com/gocodebox/lifterlms/blob/4.19.0/includes/class-llms-sessions.php#L214) (that need to be closed) only - as far as I can see.
I think we should definitely avoid storing the date using php local time, we need to decide whether we want to store it in GMT (`gmdate()`) or using local wp timezone.
Historically we save dates using wp timezone, but I'd rather prefer storing dates in GMT.
We should probably build a db update routine too to fix server side stored event dates...(?)
### Error Messages / Logs
```
n/a
```
### System and Environment Information
```
LifterLMS 4.19.0
WordPress 5.7.0
```
### This issue has been recreated:
+ [x] Locally
+ [ ] On a staging site
+ [x] On a production website
+ [x] With only LifterLMS and a default theme
### Browser, Device, and Operating System Information
n/a
### Related User Information
HS-158540
Contributor guide
Assessment
This issue has not been assessed yet.