-1

How to insert the result:

<script>
var date = new Date();
document.write(date.getTimezoneOffset());
</script>

in

{{ post.published_at|date_modify("+999 mins")|date("m/d/Y") }} 

paste instead of 999.

MaxxQ90
  • 19
  • 4
  • 1
    Does this answer your question? [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – DarkBee Jul 29 '20 at 10:04

1 Answers1

0

Is this solution safe (correct)?

  1. Passed the value in cookie:
<script>
    var now = (new Date().getTimezoneOffset()*-1);
    document.cookie = "timezoneoffset="+now;
</script>
  1. Took it to {{ var }}:
     function onStart()  { 
                    if(isset($_COOKIE["timezoneoffset"])) {
                            $time = $_COOKIE["timezoneoffset"];
                            }
                            else {
                            $time = 0;
                            }
                    $this['var'] = $time;
                }
  1. Ajax updated the partial:
{{ post.published_at|date_modify("+" ~ var ~ "mins")|date("m/d/Y") }}
MaxxQ90
  • 19
  • 4