LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-17-2019, 06:40 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 9.2
Posts: 1,155

Rep: Reputation: 51
html forms and UTC time


Is it possible to only have one of two HTML FORM options available in an HTML page according to UTC time (not visitor's local time)?

What I am trying to solve is that one of these two options should only be available to visitors on a particular day of the month in UTC time while the other option should be always available. This seems to be more a server-side issue but I can't figure how to start - css or Bash CGI or Javascript or whatever (I have not used PHP for more than ten years).

Alternatively, making the form available for a particular day of the month local (visitor's) time could be tested as a last resort.

Thank you for your help.
 
Old 08-17-2019, 09:35 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,094

Rep: Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931
Have the server serve up a different form depending the date or time.

Also, keep in mind that "the visitor's local time" and "the server's UTC time" are the same time, just in different units. If you know one, you know the other.

Last edited by dugan; 08-17-2019 at 09:45 AM.
 
1 members found this post helpful.
Old 08-17-2019, 11:09 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 18,927

Rep: Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851Reputation: 2851
Displaying a form option based upon UTC should be fairly easy regardless of scripting language i.e PHP, bash or whatever. PHP has lots of ways to compare dates and a google search should find lots of information.

Server-side has no knowledge of a clients local time.

Code:
<form ...> 
...
<?php
#get date
#add special form option using checkbox as an example.
if ( $today=="some date" )
   print("<input type=checkbox name=\"special checkbox\" value=\"1\">");
?>
...
</form>
 
2 members found this post helpful.
Old 08-18-2019, 03:38 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,307
Blog Entries: 9

Rep: Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309
Quote:
Originally Posted by dugan View Post
Have the server serve up a different form depending the date or time.
"The server" being apache or nginx?
Can they be shoehorned to do that?
 
1 members found this post helpful.
Old 08-18-2019, 05:18 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,094

Rep: Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931
Quote:
Originally Posted by ondoho View Post
"The server" being apache or nginx?
No, silly, the server being the BASH CGI that he mentioned.

Last edited by dugan; 08-18-2019 at 06:18 PM.
 
1 members found this post helpful.
Old 08-18-2019, 05:49 PM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,635

Rep: Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205
Quote:
Originally Posted by rblampain View Post
Is it possible to only have one of two HTML FORM options available in an HTML page according to UTC time (not visitor's local time)?

What I am trying to solve is that one of these two options should only be available to visitors on a particular day of the month in UTC time while the other option should be always available. This seems to be more a server-side issue but I can't figure how to start - css or Bash CGI or Javascript or whatever (I have not used PHP for more than ten years).

Alternatively, making the form available for a particular day of the month local (visitor's) time could be tested as a last resort.

Thank you for your help.
I would think that could be done with any server-side script. I'd try perl, but that's my go-to tool. michaelk's php example should work. Javascript could also work, I suppose. Wrap the once-a-month option in a div tag and only display that div on the appropriate day.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] UTC string shows "PM UTC" Andy Alt Debian 9 06-28-2019 07:58 AM
[SOLVED] Centos7, invalid offset for UTC for Sweden, says UTC+00 Basher52 CentOS 14 02-09-2018 10:10 PM
Timzone Issues...Local Time versus UTC time? as400 Solaris / OpenSolaris 12 09-26-2008 12:40 PM
Time is not using local time but uses UTC acummings Debian 2 11-03-2007 01:58 PM
Cannot set time/date to other time zone than UTC (Kubuntu) jamangold Ubuntu 1 12-23-2005 05:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration