473,722 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check if variable value is timestamp

20 New Member
Hello all,

I am using a script to export database values to xls. I am using an if statement to check if the value is numeric and has a length of ten digits. My problem is that when I extract the valaues from the the timestamp then the phone numbers whcih are also 10 digit lenthg numbers are also covnerted to dates! the numbers may only start with 2 or 6 and have ten digits but I am not sure that if I check with preg_match whehter they begin with these two i get to extract the data appropriately. Is there any function in php that can check if a value is a timestamp?

thank you for your help
Apr 29 '09 #1
4 9212
Markus
6,050 Recognized Expert Expert
What format is the timestamp?
Apr 29 '09 #2
Markus
6,050 Recognized Expert Expert
If they're in a consistent format (the timestamps) then you can use a preg_match()

Expand|Select|Wrap|Line Numbers
  1. $timestamp = "2009-01-20";
  2.  
  3. if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $timestamp)) 
  4. {
  5.     // Timestamp.
  6. else 
  7. {
  8.     // Not a timestamp.
  9. }
  10.  
Apr 29 '09 #3
theoni
20 New Member
@Markus

I wonder how I didn't think of that myself:(

thank you for the help
Apr 29 '09 #4
Markus
6,050 Recognized Expert Expert
@theoni
You're welcome.

Mark.

PS. Regular expressions are awful, that's why you didn't think of it :P
Apr 29 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1765
by: hendedav | last post by:
Hi gang. As with any other post, I am working on a project and have gotten stuck. I am trying to obtain a variable value in the parent webpage from an <iframe>. For instance: Parent Page code ---------------- <html> .... heading tags <body>
5
31593
by: DJTB | last post by:
Dear Group, I'd like to check if a value is defined in an enum. Example: ------------------------------------------------------ typedef enum { A_VALUE = 1,
1
1719
by: Varadha | last post by:
Hi, I am declaring a variable static char Version_No = '1' in header file header.h In a application "app.exe", i am changing the value of the variable in to '2' In the same application i am calling an function fun1() which is in another dll, MYDll.dll(which is linked implicitly to the exe) which includes the same header file header.h
3
2542
by: Helpseeker | last post by:
Hi all, I have written a small code in which i declare a static int variable and increment its value by one each time i click on a button. actually i use the int variable value in a particular URL so that i can browse to diff URL each time i click the button. Hope you understand the scenario. So here my question is how long is the value of the static variable retained from the time i click on the button, because what i observe is when the...
1
1626
by: Miguel Dias Moura | last post by:
Hello, I am working in ASP.NET/VB. I have a string created by a script. How can i display the content of that string when the page is loaded so i can check its value? Thanks, Miguel
3
1678
by: GS | last post by:
Hi, I have following value which I need to check wether it's null or not. Issue is that StartPrice itself can be a null and checking (myItem.StartPrice.Value == null) do not produce true. How do I check for null in this kind of case. I don't want to check StartPrice for null and then Value for null again as one option. I just want to check Value for null. Thanks, Greg
5
2862
by: aamirghanchi | last post by:
Hi, I need to know if anyone else came across this. The Session variable value I set in a sortCommand event handler of a datagrid does not hold on till the next sortcommand event handler and reverts back to its original value, the one I had set it before in the previous trip sortcommand event handler. I am trying to implement bidirectional sorting on a datagrid by making use of session variable Session("SDirection"). In the sortcommand...
0
2288
by: tharika_c | last post by:
Hi, We have a simple ASP.NET web application where one of the Session variables, called Session("SSO_ID") gets created and assigned a value (equal to the HTTP_HRID request variable value), inside the Session_Start event of the global.asax.vb file, since this variable is accessed by almost all the pages in the project. Besides this variable, there are other session variables which are set in the various aspx pages, as needed.
1
3410
by: pendem | last post by:
I mean can set a variable value in a script to be unchanged even after page reload? for example if i set a value of a global variable "val" to 2 ; so using onbeforeunload() or onunload(), i will change the value of variable "val" to 5; so can i in anyway get the value of variable "val" equal to 5? after loading the page..,i mean after onload() event is done/ does my question make any sense? thnx..
7
27015
by: hatch | last post by:
The project I am working on has to have start and stop buttons on a form and a label to show the eslaped time once the start button is pushed. The elapsed tome should stop when the stop button is pressed. I'm not sure how to display the elapsed time in the label. Can someone help?
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.