Sponsored Content
Top Forums Web Development A simple UNIXtime component in Vue.js Post 303025614 by Neo on Wednesday 7th of November 2018 06:54:22 AM
Old 11-07-2018
A simple UNIXtime component in Vue.js

A shout out to Scott who gave me a helping hand to turn a simple sample Vue.js app I wrote yesterday into a Vue.js component:

Code:
Vue.component("unix-time", {
  template: `<div class="time">{{unixtime}}</div>`,
  data() {
    return {
      unixtime: ""
    };
  },
  methods: {
    UpdateTime() {
      this.unixtime = Math.round(new Date().getTime() / 1000);
    }
  },
  created() {
    setInterval(() => {
      this.UpdateTime();
    }, 1000);
  }
});

For any Vue'ers who want the complete code, you can add this component to any root Vue.js element as long as the Vue instance is instantiated after the component appears in the script, for example, any root level element (like the one below) that appears after the component.

Code:
new Vue({
    el: '#myunixtime',
})

Then, in the HTML, just do something like this:

Code:
<div id="myunixtime">
      <unix-time></unix-time>
</div>

Thanks again to Scott for learning Vue.js with me and for the helping hand!

Maybe we will add this simple unixtime clock to the forums somewhere or use this component to replace the unixtime on the home page.....
This User Gave Thanks to Neo For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problems with unixtime!

Hi, i have wrote a scripts thats connect too some tables in a phpBB community. I have got contact with all of the tables but becouse phpBB uses unixtime, it is showed wrong. 0312011557 (Wednesday, 12. january, 15.57). I ask on this page becouse it is a unixpage, sow I wonder i someone has a script... (1 Reply)
Discussion started by: ett
1 Replies

2. UNIX for Advanced & Expert Users

converting localtime to unixtime

hi, how to convert the localtime to unixtime? i have date from the date command in unix i want to convert it into unixtime thnx (2 Replies)
Discussion started by: AshishK
2 Replies

3. Shell Programming and Scripting

Replace date_time to unixtime in csv.file

Hello, since hours I am trying to replace in a csv-file the date_time to unixtime. I tried sed, awk but not successful. I can not call a shell command within awk. Probably there is an easier way. Thanks in advance for your help Regards, telemi test.csv: 2010-04-22... (5 Replies)
Discussion started by: telemi
5 Replies

4. Shell Programming and Scripting

unixtime to formatted date time

Hi, I need to take the unix time and format it to a date/time string like this yyyymmdd,hhmmss I'm wrting in shell but have tried calling perl, but all the perl options I found on here puts output to Thu Jan 1 00:00:00 1970 format. Any help? Cheers Neil (4 Replies)
Discussion started by: nhatch
4 Replies

5. Shell Programming and Scripting

Multiple records need to convert UNIXtime to human readable datatime and all output in one format

Hello Experts, Below is the record i have: sample data attached I want this record of each row to be in single line and there are multiple rowise unixtime mentioned e.g 11996327 , This needs to be converted to Human readdable data and time from multiple rows Can you help me , it will be... (10 Replies)
Discussion started by: manishK
10 Replies

6. Web Development

A Simple Way to Set Meta Tags Using Vue.js

Did a lot of searching on the net and found a lot of tricky ways and Vue.js libs to set meta tags, but I wanted sometime simpler. So, given this standard HTML: <head> <title>Page Title</title> <meta name="description" content="Page Description"> <meta name="keywords" content="Page... (0 Replies)
Discussion started by: Neo
0 Replies

7. Web Development

Simple Vue.js Component to Redirect to External Web Page Using Vue Router

Vue Router has some quirks and on of the quirks is that it is not reliable when adding external links using the vue-router library. After struggling with many solutions, I have found that creating a simple Vue.js component like this one seems to work the best (so far): Component Example: ... (0 Replies)
Discussion started by: Neo
0 Replies

8. Web Development

Vue JS 2 Tutorial by The Net Ninja: A Recommended Vue.js Video Tutorial Series

A number of people have asked me how to get started with Vue.js and my reply before today was to Google "Vue.js". That has changed and my recommendation to anyone who wants to learn the fastest growing, easiest to learn and use Vue.js web dev framework is to watch this video tutorial series: ... (0 Replies)
Discussion started by: Neo
0 Replies

9. Web Development

The State of Vue.js

Here is very good video from Evan You, founder of Vue.js, on the state of Vue.js State of Vuenation with Evan You Here is a nice PDF report on Vue.js Update State of Vue.js Report Vue.js is now the second most starred project on GitHub, recently surpassing Bootstrap. These two... (0 Replies)
Discussion started by: Neo
0 Replies

10. Web Development

Vue.js component: Beautiful code highlighter

Sooner than later I will render forum discussions in Vue.js to complement the standard way of showing forum threads. Today, I ran across this component, vue-code-highlight Beautiful code syntax highlighting as Vue.js component. https://www.unix.com/members/1-albums225-picture1199.jpg ... (1 Reply)
Discussion started by: Neo
1 Replies
HTML::Mason::ComponentSource(3pm)			User Contributed Perl Documentation			 HTML::Mason::ComponentSource(3pm)

NAME
HTML::Mason::ComponentSource - represents information about an component SYNOPSIS
my $info = $resolver->get_info($comp_path); DESCRIPTION
Mason uses the ComponentSource class to store information about a source component, one that has yet to be compiled. METHODS
new This method takes the following arguments: o comp_path The component's component path. o last_modified This is the last modificatoin time for the component, in Unix time (seconds since the epoch). o comp_id This is a unique id for the component used to distinguish two components with the same name in different component roots. If your resolver does not support multiple component roots, this can simply be the same as the "comp_path" key or it can be any other id you wish. This value will be used when constructing filesystem paths so it needs to be something that works on different filesystems. If it contains forward slashes, these will be converted to the appropriate filesystem-specific path separator. In fact, we encourage you to make sure that your component ids have some forward slashes in them or also all of your generated object files will end up in a single directory, which could affect performance. o comp_class The component class into which this particular component should be blessed when it is created. This must be a subclass of "HTML::Mason::Component", which is the default. o friendly_name This is used when displaying error messages related to the component, like parsing errors. This should be something that will help whoever sees the message identify the component. For example, for component stored on the filesystem, this should be the absolute path to the component. o source_callback This is a subroutine reference which, when called, returns the component source. The reasoning behind using this parameter is that it helps avoid a profusion of tiny little "HTML::Mason::ComponentSource" subclasses that don't do very much. o extra This optional parameter should be a hash reference. It is used to pass information from the resolver to the component class. This is needed since a "HTML::Mason::Resolver" subclass and a "HTML::Mason::Component" subclass can be rather tightly coupled, but they must communicate with each through the interpreter (this may change in the future). comp_path last_modified comp_id comp_class friendly_name extra These are all simple accessors that return the value given to the constructor. comp_source Returns the source of the component. object_code ( compiler => $compiler ) Given a compiler, this method returns the object code for the component. HTML::Mason, HTML::Mason::Admin, HTML::Mason::Component perl v5.14.2 2012-02-04 HTML::Mason::ComponentSource(3pm)
All times are GMT -4. The time now is 02:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy