I want to create a script which tells me when a post is posted [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to create a script in php, javascript or jquery which tells me when a post is posted like Facebook in facebook when we post a status it tells us posting time like 5 minute ago or so on. I have completed all other work.

Create a coloumn to the table where you save the post details as posted_at and have DATETIME as its data type,
Use $CurrentTime = date("Y-m-d H:i:s" ); and insert while you create the post i.e., insert
So while retrieving the data just find the difference between the posted time and current time by
$PostedTime = strtotime($FetchedData->posted_at) - strtotime(date("Y-m-d H:i:s" ));
Then you shall convert the difference time as per your wish.

You have to create function that will get one parameter "posted date" and it will calculate difference from today. it will generate string and return like "2 days ago/5 min ago" or date. it is depend on you.

Related

Format date in contact form Wordpress [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to know, how to change the date format in the contact form, if I am not wrong, it's the contact form 7.
For example: I have in one of the fields, Date of birth, but the format is shown like jj/mm/aaaa
I need to change it, in order to get this format in the field of the form mm/jj/aaaa. I want to clarify that it is not for the general settings, but for the contact form.
I've been checking around, but I haven't got any answer to my question, so probably you may help me.
Thanks to everyone and happy coding!
Regarding the documentation you can change the format with:
Administration > Settings > General > Date Format
There you should see something like this where you can change the format:

display time and date in GMT or UTC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to display GMT/UTC time with current date LIVE
i can display current time with it will be fixed until did refresh for the page
what i need to do display the time and date in UTC/GMT in my page as PHP or java code
thank you
If you want to convert your current time to another timezone lets say GMT or UTC then you can follow the following steps for javascript:
You can use moment-timezone lib.
const moment = require('moment-timezone')
const now = moment().format()
moment.tz(now, 'UTC').format()
moment.tz(now, 'GMT').format()

How to store javascript code in database? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I created a webshop for an online game where the users can buy in-game stuff. I have some special items which will be only availabe for a short period of time and I want to print out how much time left to buy it.
I wrote a JS code to countdown for a date, and now I want to store it in the database. Which is the best way to do it? Just a varchart with extremely long length? Or is it a more elegant way to deal with this?
You can use Function.prototype.toString method to convert a function into a string and then later use eval to execute the function.
You should use text type rather than varchar as it will likely be longer than maximum varchar length.
However, I would strongly discourage you to do this. A better approach would be to store something like a expiration date timestamp and calculate the availability based on that value.

Convert Time to UTC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a timepicker that allows the user to select a time. If they select 7:00pm how can I convert that to UTC 24H time?
If there is already an answer to this question and someone could direct me to it that would be great.
Since you tagged JavaScript and jQuery, I could guess you are using https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery? If so, try calling getTime method:
$('#my-timeicker-id').getTime(); // returns Javascript Date object
Check for your timepicker's API (e.g. https://github.com/jonthornton/jquery-timepicker#methods) for more.
--
In case you are using your own timepicker, you will have to implement it yourself. For learning purposes great, go for it! Otherwise don't reinvent the wheel and pick an existing solution.

javascript count backwards 23 week days from current day for stock tracking [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am working on an application to get historical stock data from yahoo finance csv api. I am having trouble creating a script that will get the current day and count back 23 weekdays (not counting weekends or holidays). The idea is that it will plug the two dates in at yahoo, get the historical data and then create a moving average. I am unsure how to do this using the date function though.
You could use the Moment.js library, if you are able to provide that to your page. You could use it to do something like this:
var today = moment();
var pastDate = today.subtract('days', 23);
// then do something with those two variables...
if you need them in a certain format before you pass them along, just call .format on them
getHistoricalData(today.format('YYYYMMDD'), pastDate.format('YYYYMMDD'));

Categories