Welcome! Log In Create A New Profile

Advanced

Timezone

Posted by tmokoena 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Timezone
August 23, 2013 01:18AM
[html="html4strict"]
<p>Hi Prof, i would like to know about: The timezone this server is located in is, I must code our country as South Africa? because I assume the server is located in Unisa. Please Prof, Course Mate to advise, about to complete an assignment. The code that I am sure about is: The timezone I live in is: Africa/Johannesburg.

Thanks You.</p>
[/html]
Re: Timezone
August 23, 2013 07:42AM
The timezone the server is located in refers to the actual server where your assignment website is being hosted, so it could potentially be anywhere in the world. This shouldn't be hard-coded but needs to be dynamically picked up from the server itself.

A hint would be to have a look at the PHP date() function and it's various options.
Re: Timezone
August 26, 2013 11:42AM
Just try using the date function.


date('H:i:s'winking smiley;

This will automatically pic the time zone according to your local machine, which is the time zone you live in.
Re: Timezone
August 26, 2013 12:01PM
WIth regard to server time zone, I did use ini.servername which is zymic but have been presented by an unusual date which I'm not sure if this is the correct way of displaying the server time zone.
date('zymic.ini'winking smiley;
.
output: 2371308432013-08-26T11:43:03+02:00.43843

I would like again to find out how to display the previous date, in this case the date four days ago.
avatar Re: Timezone
August 26, 2013 12:40PM
Re: Timezone
August 26, 2013 01:32PM
@Nathaniel...

The date function returns an integer value... so you can apply operators as per usual
Re: Timezone
August 26, 2013 01:54PM
@Nathaniel

Language: PHP
date(';H:i:s';);

The value returned by this isn't really directly connected to any one specific timezone at all, but to all of them in a sense. Time != Timezone if that helps at all.

Also, that command will return the requested information related to the server, not the client, since PHP is a server side code. While testing your code through your local EasyPHP servers it would appear that the above code returns your clients' date/time info, but only because your "webserver" and "client" is actually the exact same system. Once you move the code to a host on the web it'll be easier to pick up on this.
avatar Re: Timezone
August 26, 2013 02:31PM
You can determine the default Timezone with -

Language: PHP
echo date_default_timezone_get();



and set the default Timezone with -

Language: PHP
date_default_timezone_set(DONT POST COMPLETE CODE!);
Re: Timezone
August 26, 2013 03:33PM
Hi, can anyone help me on how to display the date four days ago. This should be a previous date.
I could not be able to display this.
I tried to display it using:


mktime (date('D - 4'winking smiley, date('F d,Y'winking smiley);

But could not get the right results. The output was nothing, however I received the following error:

Warning: mktime() expects parameter 1 to be long, string given in C:\Users\41110641\Documents\EasyPHP-DevServer-13.1VC9\binaries\home\codesource.php on line 15
avatar Re: Timezone
August 26, 2013 04:08PM
Use strtotime - (String to timestamp)

Language: PHP
echo date(';d-m-Y';,strtotime("DONT POST COMPLETE CODE!"));



You can also look at DateTime add.
Re: Timezone
August 27, 2013 11:35AM
Thanks bigron11, I got it and it's fine.
Re: Timezone
August 27, 2013 02:09PM
Hi, I would l have already created an account with free webhosting but I'm not sure how to save my site in order to be viewed by the lecture and wether I should save it as an html or I should use php to save it.
Re: Timezone
August 27, 2013 02:19PM
41110641 - Nathaniel Wrote:
-------------------------------------------------------
> Hi, I would l have already created an account with
> free webhosting but I'm not sure how to save my
> site in order to be viewed by the lecture and
> wether I should save it as an html or I should use
> php to save it.

The file has to be .php - ie. index.php
avatar
Mac
Re: Timezone
August 27, 2013 05:14PM
Correct.

As a side note.... for some reason many students refer to me as a lecture.

From Wikipedia - a lecture is an oral presentation intended to present information or teach people about a particular subject, for example by a university or college teacher (lecturer) smiling smiley

So, going beyond my duties, as an educator... I am a lectureR smiling smiley
Re: Timezone
September 01, 2013 01:01AM
HI Guys,

After some googling and googling I had reach a conclusion that PHP does not include a function to get client timezone and it seems all people solution to this is to have JAVASCRIPT do the job for you. I might be wrong but guys if you have a solution to this please help me.

Thank you

Nyoka
Re: Timezone
September 02, 2013 09:26PM
@nyokahombe ,but with javascript i think you need to know basic ajex .i did it with javascript using cookies and the date() object but to write cookies with javascript and display them at the sametime using php you need to reload the page twice.
Re: Timezone
September 19, 2013 01:39AM
Hi Guys,

So assignment one its now gone and I am still here trying figure out how to get the client timezone as Mac have assured that there is function to do this in PHP and we need do more googling. I got this link http://www.justin-cook.com/wp/2006/11/29/determine-a-visitors-location-by-their-ip-address/ to share with you guys. It shows how to determine client location by IP address. It might not be the right way to get the timezone but its gets us closer.

Otherwise, we need to submit to Mac that we dont seem to be getting this function of getting client timezone and we could only ask a hint from him.

Thank you

Nyoka
avatar
Mac
Re: Timezone
September 19, 2013 07:32AM
The link you posted is about IP address - nothing to do with timezone. You simply have to Google ""get timezone of server PHP" and soemthing like "timezone difference PHP" to get and answer. The PHP manual has many function related to timezone
Sorry, only registered users may post in this forum.

Click here to login