Cornhusker40 Posted February 10, 2011 Share Posted February 10, 2011 Hi, I'm a newbie here, and with PHP, and need some help with the datetime display. I am wanting to utilize old Naval comms DTG (datetimegroup) format which is DDHHMM 3-digit Month 2-digit year. The DDHHMM = Day (01 - 31) HH (hour 01 - 24) MM (minute 00 - 59) What I need to do is to add the letter Z (meaning GMT, ZULU) like thus DDHHMMZ FEB 11 How can I go about inserting that Z into this? Tks in advance for any assist Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 10, 2011 Share Posted February 10, 2011 Where are you getting the data and time from? The current time, a database record, or where? Quote Link to comment Share on other sites More sharing options...
Cornhusker40 Posted February 10, 2011 Author Share Posted February 10, 2011 Sorry, I'm using the following in my script $stime = date("dHi M y",(time())); and I store it in a MySQL db as TEXT. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 10, 2011 Share Posted February 10, 2011 You'd be better off to store it in the database in a DATETIME field type, then format it when it's displayed . . . Quote Link to comment Share on other sites More sharing options...
Cornhusker40 Posted February 10, 2011 Author Share Posted February 10, 2011 Tks. Either way I go I have to find a way to insert the letter Z after the DDHHMM. That's my problem. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 10, 2011 Share Posted February 10, 2011 if you store the value as datetime, you can reliably pull it from the database and use date() function to put the Z wherever you need it by escaping it with a backslash: \Z Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 10, 2011 Share Posted February 10, 2011 Using date(), all you need to do is escape the Z in the formatting string. $stime = date("dHi\Z M y",time()); Quote Link to comment Share on other sites More sharing options...
Cornhusker40 Posted February 10, 2011 Author Share Posted February 10, 2011 Bingo! Tks Pikachu2000, that's what I needed Appreciate it vm, tks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.