Welcome! Log In Create A New Profile

Advanced

TimeZones

Posted by Mariuspienaar 
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
TimeZones
January 28, 2013 01:04PM
Good day!

All right, assignment 1 is easy,but what i want to know is the thing about the timezone.
Is there a PHP code for the zones,because the only timezone thing i can see is that im in the "Africa/Johannesburg" zones(by Googling), so do I just put that name as a string into a variable and echo it back or is there a much more complex way than that which they need? I cannot see that it can be that easy.
avatar Re: Assignment 1
January 28, 2013 01:45PM
Hi

Use the date_default_timezone_get() and date_default_timezone_set() functions. You can google their names to find out how to use them. Also read up on the default timezone that is in the php.ini file.

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
Re: Assignment 1
January 31, 2013 01:11PM
o The timezone this server is located in is x
o The timezone I live in is x
The above is giving me grey hair - im not giving up though
Re: Assignment 1
February 04, 2013 12:59PM
Hey guys - I'm making a progress with assignment 1
Re: Assignment 1
February 07, 2013 01:47PM
Regarding this statement in tut101:
that is completely programmed in the PHP language (that is, you must use PHP to generate the page in its entirety)

Can I go add the <html> <head> tags and only enter php on page where it is necessary?
Or do we have to do something like this:

Language: PHP
$htmlStart = "<html><head>"; $title="<title>Assignment 1</title>"; $bodyStart="</head> <body>"; $otherPHP = “my PHP code (containing other var etc)$endingHtml=" </body> </html>";

and then just :

Language: PHP
echo $htmlStart; echo $title; echo $bodyStart; echo $otherPHP

if I do it the second way, all my code appears on one line when I view source.
avatar Re: Assignment 1
February 07, 2013 02:09PM
You could also build the entire page inside one variable and then echo that variable at the end. To get the markup to look nice in the browser's "view page source", you could add a "Enter/new line" inside the quotes and it will place the markup the same way. use the concatenation operator to build the string like this:

Language: PHP
$title = "My Site"; $myVar = "<p>Hello there</p>";   $page= "<!DOCTYPE html> <html> <head> <title>".$title."</title> </head> <body> ".$myVar." <body> </html>";   echo $page;

The code in the browser will output nicely on many lines. The output of the above code would be:

Language: HTML
<!DOCTYPE html> <html> <head> <title>My Site</title> </head> <body> <p>Hello There</p> <body> </html>

Notice what I did with $title and $myVar. You can create and get all the values you need in the start of the script then build when you have everything you need. You could do this with all the vars and build the page like that then just echo the complete string at the end. This will make it easier to keep track of where you put what in the final page. Practicing this will help with understanding MVC later on because the $page will basically be the view, getting the information will be in the model and putting it all together will go in the controller. smile

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
avatar
Mac
Re: Assignment 1
February 07, 2013 02:51PM
Just to get some order here please. A descriptive topic title would have been Timezone. Because what is going to happen now is that ALL assignment 1 questions are going to be posted here, as is already happening. Help to make it easy to navigate the forum please, making sure you delimit the topic with a descriptive title. This approach is explained at length in the tut. Else I am going to close this topic... sad smiley
Re: Assignment 1
March 02, 2013 10:35PM
Hi all. I am also battling with timezone
Sorry, you can't reply to this topic. It has been closed.