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
Viewport(3I)						    InterViews Reference Manual 					      Viewport(3I)

NAME
Viewport - scrollable view SYNOPSIS
#include <InterViews/viewport.h> DESCRIPTION
Viewport is a subclass of MonoScene that allocates its component exactly as much space as it wants (determined from its shape). This space will be clipped to the viewport's size and the viewport maintains a perspective to adjust the portion of the component that is actually displayed. If the component is smaller than the viewport's canvas, then the viewport background will be filled with a light gray pattern. PUBLIC OPERATIONS
Viewport(Interactor* = nil, Alignment = Center) Construct a new viewport. If the interactor is not nil, it is inserted as the viewport's component. The second parameter deter- mines where the component is placed relative to the viewport. Insert(Interactor*) Set the component interactor. void Change(Interactor*) A viewport does not propagate changes. Thus, if the component's shape changes the viewport simply resizes the component according to the new shape. void Remove(Interactor*) Take out the component interactor. virtual void Adjust(Perspective&) Change the viewport's perspective to the given one. This operation will cause the desired area of the component to be drawn. void AdjustTo(float px, float py, float zx, float zy) void AdjustBy(float dpx, float dpy, float dzx, float dzy) void ScrollTo(float px, float py) void ScrollXTo(float px) void ScrollYTo(float py) void ScrollBy(float dpx, float dpy) void ScrollXBy(float dpx) void ScrollYBy(float dpy) void ZoomTo(float zx, float zy) void ZoomXTo(float zx) void ZoomYTo(float zy) void ZoomBy(float dzx, float dzy) void ZoomXBy(float dzx) void ZoomYBy(float dzy) Short-hand operations for explicit manipulation of the viewport's perspective. float XPos() float YPos() float XMag() float YMag() Short-hand for retrieving information about the current perspective. SEE ALSO
Perspective(3I), Scene(3I), Shape(3I) InterViews 10 February 1988 Viewport(3I)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy