473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Date/Timezone not working

1 New Member
Hello all,

I have search for hours over the internet trying to find a solution with no luck. I am hoping someone here may have to the knowledge to help me with this problem. I am trying to add the date to my site using PHP with a default timezone (the clients). Currently I have:
Expand|Select|Wrap|Line Numbers
  1.     <?php
  2.     echo date("m.d.y T");
  3.     ?>
Which prints: 08.06.07 CDT

I want to set a default timezone to PST time. I found a script that said:

date_default_ti mezone_set('UTC '); and I added it like so:
Expand|Select|Wrap|Line Numbers
  1.         <?php
  2.         date_default_timezone_set('PST'); 
  3.     echo date("m.d.y T");
  4.     ?>
To my dismay, the entire page went blank. I cannot for the life of me figure out how to get this working. Does anyone have a suggestions? They would be GREATLY appreciated.
Aug 6 '07 #1
3 5579
kovik
1,044 Recognized Expert Top Contributor
putenv('TZ=foo' ) may be of interest.
Aug 7 '07 #2
Motoma
3,237 Recognized Expert Specialist
What version of PHP are you using? Timezone related functions are only available in 5 and up. You should turn on debugging messages as stated in the first post in this forum in order to find out why the script is halting.

The date function in versions earlier that 5 return the same value that running the date command will; if you have access to the server you can change this yourself, otherwise you will need to do a little work to get the time you are looking for.

Hello all,

I have search for hours over the internet trying to find a solution with no luck. I am hoping someone here may have to the knowledge to help me with this problem. I am trying to add the date to my site using PHP with a default timezone (the clients). Currently I have:

<?php
echo date("m.d.y T");
?>

Which prints: 08.06.07 CDT

I want to set a default timezone to PST time. I found a script that said:

date_default_ti mezone_set('UTC '); and I added it like so:

<?php
date_default_ti mezone_set('PST ');
echo date("m.d.y T");
?>

To my dismay, the entire page went blank. I cannot for the life of me figure out how to get this working. Does anyone have a suggestions? They would be GREATLY appreciated.
Aug 10 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, cmccarthy. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

If you're getting a blank page, your script is probably generating an error. Check out this article to find out what is going on.
Aug 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3903
by: praba kar | last post by:
Dear All, In Php we can print RFC 2822 formatted date by date('r') with parameter r. Then it will print the below format date. "Thu, 7 Apr 2005 01:46:36 -0300". I want to print same RFC 2822 format in python. Is it possible in python? . If possible kindly mention the function related to print RFC format date
15
43021
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our code has worked satisfactorily with many databases, including many instances MS SQLServer 2000...
16
2110
by: WindAndWaves | last post by:
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always a day behind....
6
4841
by: Jim Davis | last post by:
Before I reinvent the wheel I thought I'd ask: anybody got a code snippet that will convert the common ISO8601 date formats to a JS date? By "common" I mean at the least ones described in this W3C note: http://www.w3.org/TR/NOTE-datetime For my requirements the code would be need to be open sourceable under the BSD license.
3
1487
by: Jeremy Chapman | last post by:
I've created a web service method which looks like public MatchResult CheckMatch(MatchData MatchValues) MatchData is a class defined as: public class MatchData { public string GivenName; public string FamilyName; public DateTime BirthDate; public string Gender;
10
4789
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the value for the parameter of an SqlCommand for inserting the xml document in a column of a table where the column is typed to be of the same xml schema. This all sounds simple, but SQL Server REQUIRES the timezone to be specified for date values....
7
4268
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the UTC dates sent by the browser are being adjusted for timezones by the server, but we do not want dates adjusted for timezones. For example, the user enters the date of a transaction as '25 May 2007'. That ends up as a javascript Date()...
2
3690
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the correct client time zone. Note that Exchange stores everything in UTC time. I am able currently able to use javascript to ask the client what time zone they are in, but this is only for the "today" (the current day) and not for a day in the...
6
1390
by: DavidPr | last post by:
I have a website that allows people to post ads. Ads remain active for 30 days. In their control panel they can manage their ads, i.e., Edit, Delete, Renew, etc. In this case I'm working with the "Renew" feature. I want to show how many days they have left before their ad becomes inactive. When they submit an ad the date is recorded in the database using MySQL's DATE function. (I'm not interested in the "time", just the date). Here's how I...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.