S
S
Sergey2015-11-06 02:23:51
JavaScript
Sergey, 2015-11-06 02:23:51

How to change the phone number on the site depending on the time?

It is strange that there is no such solution in the Runet.
The essence is as follows: during working hours from 08:00-17:00, the office phone is shown, and at other times - a mobile phone.
I noticed that targeted calls are missed, and there are no funds to update the PBX yet.
Apparently a simple function in JS, but I'm weak in it. Help me please :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fet, 2015-11-06
@dpmango

If it's already quite simple for your locality, where date('h') is the server time. You can date('h')+n - where n is the time difference between your location and the server.

<?php
if(date('h') >= 18 and date('h') <= 7){
 echo "звоните на мобильный";
} else {
 echo "звоните на рабочий";
}
?>

If you complicate it, for different regions, then you can pull out the user's time and substitute it in the code.

A
Alexander Taratin, 2015-11-06
@Taraflex

stackoverflow.com/a/8047891
https://api.jquery.com/text/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question