First of all I apologize for asking yet another web related time & timezone question. I know there are a lot of resources and similar questions but I still can't understand how the time conversion between php and js time works.
So here is my case. I want to get the server time including timezone into javascript and do certain operations on the client side (which are not relevant to this question). I have this short snippet that does not work as I am expecting it to:
get_date.php
<?php
date_default_timezone_set('Romania/Bucharest');
echo date('D M d Y H:i:s');
?>
index.html
<body>
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type='text/javascript'>
$.get( "get_date.php", function(data) {
current = new Date(data);
alert(current);
});
</script>
</body>
the alert message
So the problem is that I am getting the date and time for Romania (the location of the server), but the offset and timezone of Berlin (the location from where I am accessing the website). I would like to get the server time, date, offset and timezone correctly in Javascript, independent of the user location. For example the alert message should be Thu Feb 12 2015 13:26:10 GMT+0200(EET)
.
Also any clarifications of why this not work as expected are welcome!