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 Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/ 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? Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172453 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. Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172466 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 . . . Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172474 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. Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172477 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 Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172482 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()); Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172484 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. Link to comment https://forums.phpfreaks.com/topic/227303-datetime-useage/#findComment-1172489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.