473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

check if variable value is timestamp

20
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 9188
Markus
6,050 Expert 4TB
What format is the timestamp?
Apr 29 '09 #2
Markus
6,050 Expert 4TB
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
@Markus

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

thank you for the help
Apr 29 '09 #4
Markus
6,050 Expert 4TB
@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
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...
5
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
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...
3
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...
1
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
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...
5
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...
0
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),...
1
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.